📜  decode utf8 whit python - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:04.944000             🧑  作者: Mango

代码示例1
import codecs
BLOCKSIZE = 1048576 # or some other, desired size in bytes
with codecs.open(sourceFileName, "r", "your-source-encoding") as sourceFile:
    with codecs.open(targetFileName, "w", "utf-8") as targetFile:
        while True:
            contents = sourceFile.read(BLOCKSIZE)
            if not contents:
                break
            targetFile.write(contents)