小智 6
尝试这个
#read input file
with codecs.open('USERS.CSV', 'r', encoding = 'latin-1') as file:
lines = file.read()
#write output file
with codecs.open('1_UserPython.CSV', 'w', encoding = 'utf_8_sig') as file:
file.write(lines)
Run Code Online (Sandbox Code Playgroud)
要将文件从 utf8 转换为 cp1252:
import io
with io.open(src_path, mode="r", encoding="utf8") as fd:
content = fd.read()
with io.open(dst_path, mode="w", encoding="cp1252") as fd:
fd.write(content)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21460 次 |
| 最近记录: |