因为编码的原因,如果直接用:
print "你好!";
SyntaxError: Non-ASCII character '\xe4' in file C:/Users/*/PycharmProjects/HelloWorld/HelloWorld.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for detail
上面的链接给了解决方案,只要在文件开头加上这么一句:
# -*- coding: utf-8 -*-
每次添加很麻烦,所以可以把它写进模板里面,一劳永逸。模板修改在:file->setting->file and code templatea ->python script 。修改完是这样的效果 :
来源:oschina
链接:https://my.oschina.net/u/140269/blog/180745