标签:
Python 在输出中文时如果未指定编码,在执行过程会出现报错:
SyntaxError: Non-ASCII character ‘\xe4‘ in file test.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
这时只要在文件开头加入 # -*- coding: UTF-8 -*- 或者 #coding=utf-8 就行了。
例:
#coding=utf-8 #!/usr/bin/python print "你好,世界";
输出如下:
你好,世界
标签:
原文地址:http://www.cnblogs.com/jim-hwg/p/4660541.html