Use Sublime Text 3 as a Python editor for Chinese issues

Source: Internet
Author: User
Tags sublime text



Sublime Text 3 is a very useful editor, use it as a Python editor, need to solve the Chinese support problem, there are two common problems, one is the Chinese garbled problem, the second is the runtime Python console can not output Chinese.



First, Chinese garbled problem



1. If you are downloading the sublime Text 3 in the official website, then the first need to install a Package control pack, which is used to install other plug-ins, no matter what plug-in, the first thing to load this package. Press ctrl+~ shortcut key to bring up a small text, then paste the following code:


Import Urllib.request,os; PF = ' package control.sublime-package '; IPP = Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); Open (Os.path.join (IPP, PF), ' WB '). Write (Urllib.request.urlopen (' http://sublime.wbond.net/' + pf.replace (', '%20 ')) . Read ())


So sublime Text will install the package Control we need. Otherwise, the package will not be found later.



2. After restarting sublime text, in sublime text, press Ctrl+shift+p to open the command line mode, enter the install package keyword, and then click the first item in the Automatic drop-down menu: Package Control : Install package. At this point you will see a = sign in the lower left corner to move around, wait a moment.


      3. Once again, a drop-down menu appears at the command line. Enter "ConvertToUTF8" or "GBK Encoding support" to select a match. Chinese characters are displayed as normal.

    1. Second, the operation console can not output Chinese solution


The default compiler can run Python directly by ctrl+b compile and output the results in the console. In the ointment is unable to output Chinese, you need to manually configure some. In Sublime Text 3, click menu Tools->build system->new build System, paste the code below and save as Python.sublime-build. The file will be stored in the C:\Users\Administrator\AppData\Roaming\Sublime Text 3\packages\python\, if there is no Python directory, can be new. Restart the sublime.


{
    "cmd": ["python","-u","$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "encoding": "cp936"
}













Use Sublime Text 3 as a Python editor for Chinese issues


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.