Python error "Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 22-26:ordinal not in range (128)" Problem solving

Source: Internet
Author: User

The scenario is to create a new sitecustomize.py under the Python lib\site-packages folder, with the following content:

Python code:

# Encoding=utf8

Import Sys

Reload (SYS)

sys.setdefaultencoding (' UTF8 ')

Now restart the Python interpreter, execute sys.getdefaultencoding (), found that the encoding has been set to UTF8, after multiple restarts, the effect is the same, because the system when the Python boot, the file itself, set the system's default encoding, Without the need to manually add a solution to the code each time, is a solution.

Python error "Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 22-26:ordinal not in range (128)" Problem solving

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.