Configure IDLE to use Unicode

烂漫一生 提交于 2019-12-05 21:15:26

Just put special comment line at the beginning of the Python file:

# -*- coding: utf8 -*-

1) Navigate to the folder with your current version of python. Mine is: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources 2) View the python application package, as this is the IDLE. 3) You should see a file called Info.plist containing the line- <?xml version="1.0" encoding="UTF-8"?> 4) Here you can modify the encoding, keep in mind python dose not support all source encoding options.

Python support following default encode type:

  **Python 2.x: ASCII**
  **Python 3.x: UTF-8**

If you are using python 2.x, then want to use UTF-8, Please add following code to your python file:

 #!/usr/bin/python
 import sys
 sys.setdefaultencoding("utf-8")

This will override the default encoding type.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!