Python中matplotlib影象裡的中文輸出問題
阿新 • • 發佈:2019-01-09
Python, matplotlib影象裡的中文輸出問題
1.Python設定中文編碼:
import sys
reload(sys)
sys.setdefaultencoding('utf8')
2.Python使用matplotlib想要在圖中輸出漢字需要設定類似
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] =False #減號unicode編碼
3.Python裡的的字型型別,初始編碼型別為str,用GBK編碼,型別為unicode
text = open('summary.txt' ).read()
print type(text)
text = text.decode('GBK')
print type(text)