The example of this article describes the Wxpython window Chinese garbled solution, share for everyone for reference. Here's how:
Save File as Utf-8
Add #-*-Coding:utf-8-*-at the beginning of the file
Add u or u before Chinese string, for example: U "My site: http://www.bitsCN.com"
Examples are as follows:
The code is as follows:
#-*-Coding:utf-8-*-
Import WX
The Class App (WX. APP):
def OnInit (self):
frame = wx. Frame (Parent=none, Title=u ' My site: http://www.bitsCN.com ')
Frame. Show ()
Return True
App = App ()
App. Mainloop ()
Unicode string:
Unicode is the standard method of writing international texts. If you want to write text in your native language, such as Hindi or Arabic, then you need to have a Unicode-enabled editor. Similarly, Python allows you to work with Unicode text-you only need to prefix the string with u or U. For example, U "This is a Unicode string.".
Also remember to use Unicode strings when you are working with text files, especially if you know that the file contains text written in a language other than English.
Hopefully this article will help you with Python programming.