【发布时间】:2014-06-02 10:32:12
【问题描述】:
作为这个问题的后续:split elements of a list in python
给定列表:
l = ['element1\t0238.94', 'element2\t2.3904', 'element3\t0139847', '']
我如何获得\t 之后的所有内容?
我试过了:
>>> [i.split('\t', 1)[1] for i in t]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
是因为我最后有''吗?如何排除?
【问题讨论】:
-
user1899415,你能接受答案吗?近一年来你有两个答案。