Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

convert string to dictionary in python

Cool trick to convert strings into dictionary object in Python ProgrammingMethod 1: Using ast.literal_eval## Exampleimport aststrr = "{'a': 1, 'b': 2, 'c': 3}"strr_dict=ast.literal_eval(strr)Method 2: Using json## ExampleCheck here http://docs.python.org/library/json.h...