-1

Python doesn't save the file with Hebrew characters. How do I fix this? (Python 2.7)

enter image description here

The example image shows a file in the SPE IDE with a first line of

heb = ["ד" ,"ג" ,"ב", "א", ...]
dda
  • 6,030
  • 2
  • 25
  • 34

3 Answers3

1

Add this line at the top of your file to specify the encoding:

# -*- coding: utf-8 -*-

PEP 0263 - Defining Python Source Code Encodings

Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
1

The editor is trying to save in an encoding that doesn't support the characters you use. Specifying the encoding in the file, with

# -*- coding: utf-8 -*-

And tell SPE to save in UT-F8 (in the settings somewhere).

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
0

It's not clear whether the problem is with your IDE or Python.

To get Python to behave properly, you need to declare the source file encoding in the source.

msw
  • 42,753
  • 9
  • 87
  • 112