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

本文转自:
http://www.linuxsky.cn/bbs/viewthread.php?tid=494&extra=page%3D1


#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()