Python EOL While scanning string literal problem solving method

Source: Internet
Author: User
There is a scheduled task in the project, the daily fetch some table data to an external interface, but there is always an exception, today checked the next reason.

First of all, the local and test environment to test the program is not a problem, only the online environment will be thrown in the log exception, guess the exception is mainly caused by the exception of the data.
However, the data is not known, and the output log and data printing of the program is added, and the function and data record of the error are located in several runs.

The exception is this:

The code is as follows:


EOL while scanning string literal: , line 1, POS 7

Google, the cause of this exception is the string, the quotation marks do not appear in pairs, which is similar to the following situation

The code is as follows:


STR (' 1)
Traceback (most recent):
File " ", line 1, in
EOL while scanning string literal: , line 1, POS 7


Think of the program is not such a problem, the problem is from the database records, after the discovery of the database has a field maximum length is 65k, and the data deposited more than 65k, the entire string is truncated.

The entire string is not a generic string, but rather a dictionary of character form, similar to STR (DICTA)
Dica a key or value is truncated for example from {"Name": "Orangleiu"} to {"name": "Orang
Therefore, when the conversion to the STR type of the time of the error.

Adding exception handling and field growth lengths solves the 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.