> a = "{'a':'1','b':'2'}"
> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
See also the ast.literal_eval function:
http://docs.python.org/py3k/library/ast.html#ast.literal_eval
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
aimeixu wrote:
> a = "{'a':'1','b':'2'}"
> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
You could evaluate it as regular Python code, using "exec":
res = {}
exec("a={'a':'1'}", res)
print res['a']
However, if this is input from a file or the user, be aware that this opens
On Mon, Aug 9, 2010 at 2:53 AM, Shashwat Anand wrote:
> On Mon, Aug 9, 2010 at 3:03 PM, aimeixu wrote:
>> Hi,
>> I am newbie for python ,Here is my question:
>> a = "{'a':'1','b':'2'}"
>> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
>> Thanks a lot .Really need help.
>
> Parse t
On Mon, Aug 9, 2010 at 3:03 PM, aimeixu wrote:
> Hi,
> I am newbie for python ,Here is my question:
> a = "{'a':'1','b':'2'}"
> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
> Thanks a lot .Really need help.
>
Parse the string and re-create the dictionary.
>>> s = "{'a':'1','b'
Hi,
I am newbie for python ,Here is my question:
a = "{'a':'1','b':'2'}"
how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
Thanks a lot .Really need help.
--
http://mail.python.org/mailman/listinfo/python-list