Le 14/08/2014 15:31, YBM a écrit :
Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit :
Hello,

This very simple program runs well on windows 7

# -*- utf8 -*-
print('Réussi')

But, when I start the vrey same file on Linux (ubuntu 14), I got:

Traceback (most recent call last):
   File "/partages/bureau/PB/Dev/Python3/test.py", line 2, in <module>
     print('R\xe9ussi')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128)

What should i do to let the same program run on both OS, without changes?

the correct comment line should be : # -*- encoding: utf-8 -*-
and it could be usefull to begin with #!/usr/bin/env python
or #!/usr/bin/env python3 :

$ cat > réussi.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
print('Réussi');
^D
$ chmod +x réussi.py
$ ./réussi.py
Réussi
$ python réussi.py
Réussi


Nothing to do with the file encoding.

... if the OP use really Python 3
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to