Tag:python3.x
Article From:https://segmentfault.com/q/1010000012147600
Question:

Oh, good heartache
Locally written code, uploaded to the server test makes mistakes.

For example, what is the result of this problem? Is the GCC version too high?

Answer 0:

The same problem was encountered before reading the file.

The same py script is executed on its own virtual machine and runs successfully. Put it wrong on the server.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

1、Unsolvable using the codecs module

2、Try to use decode and encode

3、All sorts of search for Baidu and Google

Step up and find that even if the file is not read

print(“Any Chinese “)
The same mistake

The final solution:

Change the CentOS system language $LANG

LANG=en_US.UTF-8
Perfect solution

Leave a Reply

Your email address will not be published. Required fields are marked *