python 字符编码的两种方式写法:# coding=utf-8和# -*- coding:utf-8 -*-

python运行文件是总会出现乱码问题,为了解决这个问题,在文件开头加上:

# coding=utf-8 或者 

# -*- coding:utf-8  -*-

# coding=<encoding name>

or (using formats recognized by popular editors)

# -*- coding: <encoding name> -*-
这两种写法都没错,但是第二种支持的编辑器更多更广些。
posted @ 2017-11-22 11:08  Halo3224  阅读(17352)  评论(0编辑  收藏  举报
热爱技术的小牛