您可以使用precs模块,如下所示:
import precsBLOCKSIZE = 1048576 # or some other, desired size in byteswith precs.open(sourceFileName, "r", "your-source-encoding") as sourceFile: with precs.open(targetFileName, "w", "utf-8") as targetFile: while True: contents = sourceFile.read(BLOCKSIZE) if not contents: break targetFile.write(contents)
编辑 :添加
BLOCKSIZE参数以控制文件块大小。



