所以我的代码如下:
promotion = [[""], ["promotion applied"],[""]]
如何让它从那里进入这种状态:
promotion = ["", "promotion applied", ""]
答案 0 :(得分:1)
>>> promotion = [[""], ["promotion applied"],[""]]
>>> [x[0] for x in promotion]
['', 'promotion applied', '']
with tuple unpacking:
>>> [x for x, in promotion] # works only if all items are single-item sequences.
['', 'promotion applied', '']