Python中文显示问题

默认pyhon使用ASCII码来解释程序的,默认不支持中文,需要在程序的第一行或者第二行声明编码。

官方解决方案:https://www.python.org/dev/peps/pep-0263/

    To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:
# coding=<encoding name>
    or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
    or
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :

 

posted @ 2015-10-29 17:14  慢吞吞的蜗牛君  阅读(1148)  评论(0编辑  收藏  举报