qqruser 发表于 2015-4-27 08:03:10

将GBK汉字转化为拼音的Python小程序

#!/usr/bin/python
# -*- coding: cp936 -*-

#################################
#   Written by caocao         #
#   caocao@eastday.com          #
#   http://nethermit.yeah.net   #
#################################

import sys
import re
import string

class CConvert:
def __init__(self):
"Load data table"
try:
   fp=open("convert.txt")
except IOError:
   print "Can't load data from data.txt\nPlease make sure this file exists."
   sys.exit(1)
else:
   self.data=fp.read()
   fp.close()

def convert(self, strIn):
"Convert GBK to PinYin"
length, strOutKey, strOutValue, i=len(strIn), "", "", 0
while i=0x81 and code1=0x40 and code2
页: [1]
查看完整版本: 将GBK汉字转化为拼音的Python小程序