Fix unicodeencodeerror: ' ASCII ' codec can ' t encode problem

Source: Internet
Author: User

There's a time to convert a list to a string output today.

Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 32-34:ordinal not in range (128)


Workaround 1:

At the beginning add

Import sysreload (SYS) sys.setdefaultencoding ("Utf-8")


Workaround 2:

Run a python program with CMD to display the results normally


In addition: 1. When the string has \ n, \ t, \ r, Json.loads () failure, exception, to be removed;
2. In the operation of the database when using Basicdatasource, you can set characterencoding to solve the problem of Chinese garbled, Basicdatasource Connpool ; Connpool.addconnectionproperty ("Characterencoding", "UTF-8");;

Fix unicodeencodeerror: ' ASCII ' codec can ' t encode problem

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.