Python Run error condition

Source: Internet
Author: User

1, the error content: You must is not the use 8-bit bytestrings unless the use a text_factory the can interpret 8-bit bytestrings (like Text_fa ctory = str). It is highly recommended, instead just switch your application to Unicode strings.

Error description: Occurs when using the Sqlite3 module for DB file processing in Python;

Knowledge points and Solutions:

conn = Sqlite3.connection ("... ")
Conn.text_factory = str

Problem Solution Source: http://bbs.csdn.net/topics/250055755

Sets what type of Python to use to handle the text type of sqlite3, which is Unicode by default, so it produces
Operationalerror:could not decode to UTF-8 column ' name ' with text ' domestic other '
This error

Because the data is fetched from the database, it is GBK encoded (because the last time you saved in is GBK)
The default value for Conn.text_factory is that Unicode,python will attempt to convert a field of type text to Unicode, resulting in an error

Python Run error condition

Related Article

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.