Solution to garbled Chinese characters in the wxPython window,
The example in this article describes how to solve Chinese garbled characters in the wxPython window and share it with you for your reference. The specific method is as follows:
Save the file as UTF-8
Add #-*-coding: UTF-8 -*-
Add u or U in front of a Chinese string, for example: u "my website: http://www.bkjia.com"
Example:
Copy codeThe Code is as follows: #-*-coding: UTF-8 -*-
Import wx
Class App (wx. App ):
Def OnInit (self ):
Frame = wx. Frame (parent = None, title = u'my Website: http://www.bkjia.com ')
Frame. Show ()
Return True
App = App ()
App. MainLoop ()
Unicode string:
Unicode is a standard method for writing international text. If you want to write text in your native language, such as Hindi or Arabic, you need an editor that supports Unicode. Similarly, Python allows you to process Unicode text-you only need to add the prefix u or U before the string. For example, u "This is a Unicode string .".
In addition, remember to use Unicode strings when processing text files, especially when you know that this file contains text written in a non-English language.
I hope this article will help you with Python programming.