Revision: 21847
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 22, 2009 15:08 by magicrebirth
Initial Code
x = range(10) print x # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print str(x) # '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' print repr(x) # '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' y = str(x) z = eval(y) print x == z # 1 print z # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Initial URL
Initial Description
// Is there a way in python to convert a list say [1,2,3,4] to a string and // also how to convert a string to a list? // use str() or repr() to convert to a string. // eval() will convert back to a list.
Initial Title
Python: convert string to/from lists
Initial Tags
list, python
Initial Language
Python