Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report