Xupeng's blog

Jun 21, 2006 - 1 minute read - Comments

几行用于简繁编码转换的python代码

刚刚在list里看到有人问limodou老大以前写的简繁转换程序,就随手写了几行,试了下可以正确进行转换,也贴进了list:

#coding=gbk

chstr = "中文"

big5file = open("big5.txt","w")
big5file.write(chstr.decode("gbk").encode("big5"))
big5file.close()

txt = open("big5.txt").read()
gbfile = open("gb.txt","w")
gbfile.write(txt.decode("big5").encode("gbk"))
gbfile.close()

Tags: python

原来简繁转换并非那么简单 MacOSX x86 10.4.6安装成功,无法启动

comments powered by Disqus