py字符串处理问题?
怎样将字符串:
str1="x1","y1","z1"
>>> str1="x1","y1","z1">>> x, y, z = str1>>> x, y, z('x1', 'y1', 'z1')>>>
[解决办法]
>>> x1 = 1
>>> abc = 'string abc'
>>> y332test = ('y',332,'test')
>>> lst = ["x1", "abc", "y332test"]
>>> map(eval, lst)
[1, 'string abc', ('y', 332, 'test')]
>>>
[解决办法]
长度不定就循环一下
>>> str1="x1","y1","z1">>> for i in range(len(list(str1))): print list(str1)[i] x1y1z1>>>