Article From:

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

Perfect solution

Leave a Reply

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