标签: python list
我想改变
mylist = [['1'],['2'],['3']]
是
mynewlist = (1,2,3)
如何在python中执行此操作?
答案 0 :(得分:7)
简单的列表理解将会:
mynewlist = [int(x[0]) for x in mylist]
当然,如果你真的想要一个元组作为输出:
mynewtuple = tuple(int(x[0]) for x in mylist)