使用元组和列表从嵌套列表中删除元组
Removing tuple from nested list with tuple and lists
我有一个这样的嵌套输出:
[(3, [['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'],
['Avg_Order_Insert_Size', '22.09531308137768']])]
我想去掉元组中的 int (3),并保存包含字符串和整数的列表。
如何以最佳方式完成此任务?
我的目标是稍后使用元组中的列表创建字典,但是虽然这些整数在元组中,但我不知道该怎么做。基本上我想我想要一个输出,例如:
[([['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'],
['Avg_Order_Insert_Size', '22.09531308137768']])]
我觉得够了:
>>> value = [(3, [['Avg_Order_Insert_Size', ...
>>> value[0] = value[0][1:]
>>> value
[([['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'], ['Avg_Order_Insert_Size', '22.09531308137768']],)]
我有一个这样的嵌套输出:
[(3, [['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'],
['Avg_Order_Insert_Size', '22.09531308137768']])]
我想去掉元组中的 int (3),并保存包含字符串和整数的列表。
如何以最佳方式完成此任务?
我的目标是稍后使用元组中的列表创建字典,但是虽然这些整数在元组中,但我不知道该怎么做。基本上我想我想要一个输出,例如:
[([['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'],
['Avg_Order_Insert_Size', '22.09531308137768']])]
我觉得够了:
>>> value = [(3, [['Avg_Order_Insert_Size', ...
>>> value[0] = value[0][1:]
>>> value
[([['Avg_Order_Insert_Size', '572.9964086553654'], ['Avg_Order_Insert_Size', '34.858670832934195'], ['Avg_Order_Insert_Size', '22.09531308137768']],)]