首先用 pytty.exe登录你的 服务器
$ fc-list :lang=zh
查看你服务器的字体包


centos7 matplotlib 解决中文乱码

第一步,进入Python

centos7 matplotlib 解决中文乱码

第二步,import matplotlib,  print(matplotlib.matplotlib_fname())

centos7 matplotlib 解决中文乱码

centos7 matplotlib 解决中文乱码

第三步,根据上面的信息找到 字体包,上传字体包,我传的是  samhei

/usr/local/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf/ 我的是这个,你们根据实际的情况而定

第四步回到你的代码,加入下面的代码

centos7 matplotlib 解决中文乱码

就会发现可以识别中文了

 

相关文章: