python encoding problem

https://www.cnblogs.com/a-xu/p/4447636.html

 'gbk' codec can't encode character '\xa3' in position 0: illegal multibyte sequence

 

Error when calling print function

In fact, python3 is already utf-8 by default, why is this error still happening, because my program is running on the console

 

The console is gbk by default, so some characters gbk cannot be encoded, then change the encoding method of the console

 

If you want to change to UTF-8, you need to run the chcp command:
chcp 65001

This change is only temporary, you can change the system settings

Sometimes the newly installed system may display confusion when running some Chinese software. You can modify the system area through the control panel to manage this behavior: Control Panel - Region and Language - "Administration" tab, change "Language for non-Unicode programs" to "Chinese (Simplified, China)".

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326159448&siteId=291194637