Python 对文件进行编码转换

来源:互联网 发布:intelj java.util.map 编辑:程序博客网 时间:2024/04/30 10:28
Python 对文件进行编码转换

importsys
importchilkat
 
charset=chilkat.CkCharset()
 
#  Any string argument automatically begins the 30-day trial.
success=charset.UnlockComponent("30-day trial")
if(success !=True):
    printcharset.lastErrorText()
    sys.exit()
 
#  Set the "To" and "From" character encodings:
charset.put_FromCharset("shift_JIS")
charset.put_ToCharset("utf-8")
 
#  To do file-to-file conversion, call ConvertFile.
#  The shift_JIS sample file is downloadable from this URL:
#  http://www.chilkatsoft.com/testData/japanese_shiftJis.txt
success=charset.ConvertFile("japanese_shiftJis.txt","japanese_utf8.txt")
if(success !=True):
    printcharset.lastErrorText()
else:
    print"Success"
Python 对文件进行编码转换
0 0
原创粉丝点击