中文乱码问题

我通过下面方法解决输出中文乱码问题: 
1、设置PyCharm工具的编码格式:File--》setting--》Editor--》FileEncodings--》IDE encoding:utf-8 
2、在PyCharm模块文件的第二行加入语句:#-*-coding:utf-8-*- 
3、在File--》Setting--》File and CodeTemplates模块里加入下面的语句:

#-*-coding:utf-8-*- 
__author__ = '$USER' 

4、文件中所有的字符串前都加u,如 u"中文"


注意:#-*-coding:utf-8-*- 一定要在第一行 ,可以是#encoding=utf-8 或者#coding=utf-8 ;

           对中文来说,常见的就是utf-8和cp936(windows上为CP936),一般建议使用utf-8,这两种形式分别是# -*- coding: cp936 -*-和#-*-coding:utf-8-*- 

原文地址:https://www.cnblogs.com/sunny0824/p/13500094.html