4

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

There is no "Encoding" option in IDLE settings.

heybjm
  • 41
  • 1
  • 3

3 Answers3

1

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

# -*- coding: utf8 -*-
tav
  • 587
  • 6
  • 9
  • you don't need it on Python 3 (it is the default). It assumes (correctly) that IDLE respects the encoding declaration. – jfs Jan 06 '16 at 05:58
0

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.

PVNRT
  • 235
  • 1
  • 4
  • 14
-3

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.

jack
  • 505
  • 2
  • 7