短答案:使用Python3
长答案:
# -*- coding: utf8 -*-
# 及早将一切转到UTF-8
unicode_str = unicode('中文', encoding='utf-8')
# 打印或者写入前用UTF-8编码
print unicode_str.encode('utf-8')
# 用codecs.open替换open
import codecs
codecs.open('filename', encoding='utf8')
发布时间:2019-10-13 09:03:41编辑:auto阅读(2228)
短答案:使用Python3
长答案:
# -*- coding: utf8 -*-
# 及早将一切转到UTF-8
unicode_str = unicode('中文', encoding='utf-8')
# 打印或者写入前用UTF-8编码
print unicode_str.encode('utf-8')
# 用codecs.open替换open
import codecs
codecs.open('filename', encoding='utf8')
上一篇: Python重新加载模块方法
下一篇: 理解 Python 的 LEGB
46439
44324
35778
33330
28036
24599
23523
18741
17989
16681
4505°
5064°
4596°
4736°
5399°
4355°
4413°
4959°
4854°
6102°