Configure IDLE to use Unicode

2019-05-10 11:01发布

How do I make IDLE use UTF-8 as the default encoding for my Python files ?

There is no "Encoding" option in IDLE settings.

3条回答
淡お忘
2楼-- · 2019-05-10 11:36

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

# -*- coding: utf8 -*-
查看更多
Animai°情兽
3楼-- · 2019-05-10 11:50

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.

查看更多
乱世女痞
4楼-- · 2019-05-10 11:53

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.

查看更多
登录 后发表回答