STRING TO LIST

jubafre at brturbo.com jubafre at brturbo.com
Tue Apr 8 19:56:08 CEST 2003


Hello, 

I need to change a variable from string to list. 
> 
> >>> x=str("[[12,13],[14,15]]") 
> >>> x 
> '[[12,13],[14,15]]' 
> 
> i have x and i want to change to a list, but not in this way: 
> 
> >>> x=list(x) 
> >>> x 
> ['[', '[', '1', '2', ',', '1', '3', ']', ',', '[', '1', '4', ',', '1', '5', ']', ']'] 
> 
> must be a list like this: 
> 
> >>> x=[[12,13],[14,15]] 
> >>> x 
> [[12, 13], [14, 15]] 
> 
> someone know??? 


Juliano Freitas


More information about the Python-list mailing list