Cool Computer PC Tricks
Pages - Menu
(Move to ...)
Home
▼
convert string to dictionary in python
Cool trick to convert strings into dictionary object in Python Programming
Method 1:
Using ast.literal_eval
## Example
import ast
strr = "{'a': 1, 'b': 2, 'c': 3}"
strr_dict=ast.literal_eval(strr)
Method 2: Using json
## Example
Check here
http://docs.python.org/library/json.html
1 comment:
Sinelogix
June 21, 2013 at 6:23 PM
Useful information thanks guys
Web Designer in Bangalore
Reply
Delete
Replies
Reply
Add comment
Load more...
‹
›
Home
View web version
Useful information thanks guys
ReplyDeleteWeb Designer in Bangalore