Solution to garbled Chinese characters in the wxPython window,

Source: Internet
Author: User
Tags processing text

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.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.