SyntaxError: unexpected EOF while parsing

Error in the eval() function
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: