Sunday, 15 April 2012

python - Receive a string with values and return a list -


Then, I get a str, with values ​​like:

  some = "8478579 " 

and get me

  some = [8,4,7,8,5,7,9]  
some.split () , but it gives me : something ["8478579"].

Using an understanding of the list

  Gt; & Gt; & Gt; [Iii] For some [ii] [8, 4, 7, 8, 5, 7, 9]  

or a map

< Previous> & gt; & Gt; & Gt; Something = "8478579"> gt; & Gt; & Gt; List (map (int, some)) [8, 4, 7, 8, 5, 7, 9]

No comments:

Post a Comment