Get the App
SLTechnology News&Howtos  ›  Servers  › 

The code written under linux is written in utf-8. What if all the Chinese characters are garbled when running under XP?

Shulou Source: shulou.com Published: 2022-06-01 07:59:51 10月04日 Update

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.

Tags: Utf-8 run garbled code how to do result Chinese world hello more knowledge article practical two character string that is work meeting file article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Tech Info Apple Shulou Information MariaDB