I have an old file written using python2, which contains things like 148191387849281587952L
.
When I try to read it (using ast.literal_eval
) in python3, I, naturally, get SyntaxError: invalid syntax
.
Is there anything I could do to read the file into python3?
PS. The only solutions I see at this time require modifying the file:
Convert to JSON: read the file into python2, write it using json, then read into python3 using json.
Remove the offending
L
usingsed -i 's/([0-9]+)L/\1/g'
.Convert the file using
2to3
(suggested by @user3080953).
Is there anything better?