标签: python
我需要以这种方式从列表执行转换['2 1 ', '2 1']否则在Python中使用[['1 ', '2'], ['2 ', '1']]并且是否有任何命令来执行此操作?
['2 1 ', '2 1']
[['1 ', '2'], ['2 ', '1']]
答案 0 :(得分:0)
data = ['2 1', '2 1'] res = [item.split() for item in data] res[0] = res[0][::-1] [['2', '1'], ['2', '1']]