【发布时间】:2017-03-23 07:28:06
【问题描述】:
现在我有一个这样的列表对象:
lst = [None, None, 'one', None, 'two', None]
我正在尝试对其执行 strip() 并得到如下结果:
strip(lst)
>> ['one', None, 'two']
left_strip(lst)
>> ['one', None, 'two', None]
有没有优雅的方式来做到这一点?
ps:感谢 4 @woockashek 的建议,我已经更改了 lst
从[None, None, 'one','two', None] 到[None, None, 'one', None, 'two', None]
【问题讨论】:
-
不是一个单一的解决尝试,只是一个问题转储,这个有一个赞成票?很酷的投票。
-
现在还不清楚您想要实现什么。
[None, 'one', None, 'two', None]呢。你期待['one', None, 'two']或['one', 'two']?
标签: python