Tag: expression. Python object

Python AST: Evaluate an Expression

Do you want to convert a string of Python expression to Python object? Use ast $ cat myast.py import ast exDict = ‘{“name”: “1”}’ x = ast.literal_eval(exDict) print(x) $ python myast.py {‘name’: ‘1’} Another Example >>> import ast >>> x = u'[ “A”,”B”,”C” , ” D”]’ >>> x […]