hncys 发表于 2017-4-21 09:25:11

Python支持中文

  让Python支持中文要在Python代码头部加上
# -*- coding: cp936 -*-

  如代码:


# -*- coding: cp936 -*-
xxx = file(’e:\\python\\a.txt’,'w’)
xxx.write(’不好1\n’)
xxx.write(’line2\n’)
xxx.write(’line3\n’)
xxx.write(’line4\n’)
xxx.close()
xxx=file(’e:\\python\\a.txt’,'r’)
content = xxx.read()
print content


页: [1]
查看完整版本: Python支持中文