Pycharm中汉字乱码的处理方法

存在问题:
汉字乱码


解决方案:
利用encode和decode属性进行修正
代码如下:

from tkinter import *
root = Tk()
root.title("hello world")
root.geometry('300x200')

Label(root, text='汉子乱码处理方法'.encode('utf-8').decode('utf-8'), font=('Arial', 20)).pack()

root.mainloop()

注:1)两个属性缺一不可;
  2)encode必须在decode前面。

猜你喜欢

转载自blog.csdn.net/coberup/article/details/83003981