Python Ast.literal_eval Throwing Malformed String Error Given "datetime.datetime.now()"
I need to evaluate the string before assigning it, so I am using eval. But I read eval is not good to use and instead use ast.literal_eval. But when using ast.literal_eval, I am ge
Solution 1:
ast.literal_eval
document clearly says:
Safely evaluate an expression node or a string containing a Python literal or container display.
The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None.
Post a Comment for "Python Ast.literal_eval Throwing Malformed String Error Given "datetime.datetime.now()""