How to pass dictionary(hash value) as command line argument to python script?

Here I m passing dictionary as command line argument to python script

python post_request.py {“doctype”:“Address”,“address_title”:“Mr.Machha”,“address_line1”:“Vijayanagar”,“city”:“BangLORE”,“phone”:“012345678”}

And in my python script(post_request.py) I m getting

data= sys.argv[1]

print data
{doctype:Address,address_title:Mr.Machha,address_line1:Vijayanagar,city:BangLORE,phone:012345678}

Here I m not getting dictionary as I m passing ie

{“doctype”:“Address”,“address_title”:“Mr.Machha”,“address_line1”:“Vijayanagar”,“city”:“BangLORE”,“phone”:“012345678”}

How to get dictionary as mentioned above in my script?

Hi, through the command line you can not pass python objects like dictionaries,lists,… Of course you can try some thing like this by importing json module :

import json

data=json.loads(argv[1])

Reference : http://stackoverflow.com/questions/18006161/how-to-pass-dictionary-as-command-line-argument-to-python-script

And one more thing, you can ask these type of questions in http://stackoverflow.com instead of codechef

Thank You for your link.

I already tried that link but I m not getting out put as I want ie {“doctype”:“Address”,“address_title”:“Mr.Machha”,“address_line1”:“Vijayanagar”,“city”:“BangLORE”,“phone”:“012345678”}
that’s why i asked this question in codechef.
I m new to python so your help will be appreciated.

data={“doctype”:“Address”,“address_title”:“Mr.Machha”,“address_line1”:“Vijayanagar”,“city”:“BangLORE”,“phone”:“012345678”}
print data

output
{‘city’: ‘BangLORE’, ‘address_line1’: ‘Vijayanagar’, ‘doctype’: ‘Address’, ‘address_title’: ‘Mr.Machha’, ‘phone’: ‘012345678’}

if your new in python means, http://www.codecademy.com/ you will get overall idea about python

//