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> -*-
这两种写法都没错,但是第二种支持的编辑器更多更广些。
原文地址:https://www.cnblogs.com/my-blogs-for-everone/p/7878249.html