The code written under linux is written in utf-8. What if all the Chinese characters are garbled when running under XP?
This article to share with you is about the code written under linux when using utf-8 results get XP running all Chinese into garbled how to do, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range
Just two changes.
Step 1: Start each py file by adding
#!/ usr/bin/env python
# --*-- encoding:utf-8 --*--
statement
the second step
Each string is enclosed in u '', as in
CODE:
Hello, world.
It should be written
CODE:
Hello, world.
The above is the code written under linux when using utf-8 results get XP running all Chinese into garbled how to do, Xiaobian believe that some knowledge points may be our daily work will see or use. I hope you can learn more from this article. For more details, please follow the industry information channel.