Error in the eval() function
Correct code snippet:
Correct code snippet:
with open("COCO_train.json", "r+") as f:
data = f.readline()
data = data.strip('{').split('{')
del data[0]
del data[-1]
for i in data:
i = '{' + i[: -2]
i = eval(i)
Error code segment:
with open("COCO_train.json", "r+") as f:
data = f.readline()
data = data.strip('{').split('{')
del data[0]
for i in data:
i = '{' + i[: -2]
i = eval(i)
The general reason for this error is that the format is not correct. This error occurs when the blogger converts the string into a dictionary, because the last string is missing the} character, so delete it.
undertake Matlab, Python and C++ programming, machine learning, computer vision theory and guidance, undergraduate and master can, salted fish trading, professional answer please go zhihu, detailed talk please contact QQ number 757160542, if you are the one.
Read More:
- Syntax error: unexpected EOF while parsing
- [development experience] solution to unexpected syntax error: unexpected identifier in JSON parsing
- Python error open SSL.SSL.SysCallError :(-1,‘Unexpected EOF‘)
- Parsing error: Unexpected token
- [system]SyntaxError: Unexpected token u in JSON at position 0
- Module build failed: SyntaxError: Unexpected token
- chunk-vendors.7142f8da.js:1 Uncaught SyntaxError: Unexpected token ‘<‘
- Vue の NPM run serve error: parsing error: unexpected token<
- error Parsing error: Unexpected reserved word ‘await‘.
- psycopg2.OperationalError: SSL SYSCALL error: EOF detected
- Springboot project: error parsing HTTP request header note: further occurrences of HTTP request parsing
- ParserError: Error tokenizing data. C error: EOF inside string starting at row 917
- “Unexpected syntax error: unexpected identifier”.
- Unexpected syntax error: unexpected token<
- Parsing the exception of storing JSON string in cookie
- Solve the problem of syntax error: unexpected end of file or syntax error near unexpected token ` fi ‘error
- 12304;388382;3906442nd 123057 SyntaxError and unicode error and 8216215;
- Parsing double quotation marks with JSON
- Error: unexpected syntax error: unexpected token<
- Python SyntaxError: Non-ASCII character ‘\xe5‘ in file