2013-09-29 17 views

回答

3
[x or None for x in "1\t2\t3\t\t4".split("\t")] 
#>>> ['1', '2', '3', None, '4'] 

如果你真的想int就像在你的榜样:

[int(x) if x else None for x in "1\t2\t3\t\t4".split("\t")] 
#>>> [1, 2, 3, None, 4] 
+0

它的工作原理!谢谢! –

相关问题