demo.py(文件编码):
# *-* coding:utf8 *-*
# 在字符串前,增加一个 `u` 表示这个字符串是一个 utf8 字符串
hello_str = u"hello世界" # Python2.x中,如果要对字符串进行遍历或切片,必须用u来指定字符串的编码
print(hello_str)
for c in hello_str:
print(c)
demo.py(文件编码):
# *-* coding:utf8 *-*
# 在字符串前,增加一个 `u` 表示这个字符串是一个 utf8 字符串
hello_str = u"hello世界" # Python2.x中,如果要对字符串进行遍历或切片,必须用u来指定字符串的编码
print(hello_str)
for c in hello_str:
print(c)