[Error] EOL while scanning string literal

Source: Internet
Author: User

There is a recurring work item. Some table data for a day is required to the external interface, but recently it is always an exception. The reason for the check today.


The first local and test environment in the test program is no problem, there is a network environment will only throw an exception in the log. The main exception is the presumption of abnormal data.

, it is unknown, then added the program's output log and data printing, through a few executions to locate the error occurred function and data records.


The exception is this:

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


Google a bit. The cause of this exception is the string, which does not appear in pairs, which is similar to the following situation

STR (' 1) Traceback (most recent call last):  File "<string>", line 1, in <fragment>eol while scanning string literal: <string>, line 1, POS 7

Think of the program is not this 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, such as from {"name": "ORANGLEIU"} truncated to {"name": "Orang

Therefore, when the conversion to the STR type of the time of the error.


Adding exception handling and field growth lengths overcomes the problem.


This article is derived from "Orangleliu notebook " Blog, be sure to keep this source http://blog.csdn.net/orangleliu/article/details/38943749


Copyright notice: This article Orangleliu (http://blog.csdn.net/orangleliu/) original article, the article reproduced the Declaration.

[Error] EOL while scanning string literal

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.