This article mainly introduces the Python EOL while scanning string literal problem solving method, this article summarizes the database data problems caused by this problem, the need for friends can refer to the
There is a timed task in the project, every day to get some table data to an external interface, but there has always been an anomaly, today checked the reason.
First, the local and test environment test this program is no problem, only the online environment will throw an exception in the log, guess the main reason for the exception is the data exception.
But what data is unusual, by the unknown, so that the program's output log and data printing, through several runs to locate the error of the function and data records.
The exception is this:
The code is as follows:
EOL while scanning string literal: , line 1, POS 7
Google, the reason for 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 call last):
File " ", line 1, in
EOL while scanning string literal: , line 1, POS 7
Think of the program is not such a problem, the problem comes from the database records, after the detection of the database has a maximum length of a field of 65k, and stored data greater than 65k, the entire string was truncated.
The entire string is not a generic string, but rather a dictionary of character forms, similar to STR (DICTA)
Dica a key or value is truncated for example from {"Name": "ORANGLEIU"} truncated to {"name": "Orang
So when you take out the conversion to the STR type, the error.
Plus exception handling and field growth lengths solve the problem.