如何删除list
内部列表(Double Square Brackets)并将其作为整数类型列表。
我尝试一次选择一个元素:
enter code here
x = [['19'], ['19', '21']]
x = (int(x) for x in x)
但相反,它会产生<generator object>
。
答案 0 :(得分:0)
如果您将列表添加到一起,您将获得所需的结果,如:
sum(x, [])
x = [['19'], ['19', '21']]
print(sum(x, []))
['19', '19', '21']
答案 1 :(得分:0)
您只需要:
final_list = [i for sub_list in x for i in sub_list]