用 'b' 模式打开文件将允许你在Python2和Python3中使用相同的代码。 txt = u'his$\u2026\n' with open("/tmp/test", "wb") as fp: fp.write(txt.encode('utf-8')).
確定! 回上一頁