需求:将utf-8格式的文件转换成gbk格式的文件 实现代码如下: 1 2 3 4 5 6 7 8 9 10 11 def ReadFile(filePath,encoding="utf-8"): with codecs.open(filePath,"r",encoding) as f: return f.read() def WriteFile(filePath,u,encoding="gbk"): with codecs.open(filePath,"w",encoding) as f: f.write(u) def UTF8_2_GBK(src,dst):<