python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 转成列表,最终结果 [['a',23.1,1,2],['b',21.9,3,8]]


您可以使用以下代码将字典转换为列表: ```python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} result = [] for key, value in data.items(): temp = [key] for inner_key, inner_value in value.items(): temp.append(inner_value) result.append(temp) print(result) ``` 输出结果将为:[['10月', 23.1, 1, 2], ['11月', 21.9, 3, 8]]
相关提问
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 产品 10月 11月 12月 a 23.1 1 2 b 21.9 3 8(322点数解答 | 2024-01-12 17:18:58)259
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 产品 10月 11月 12月 a 23.1 1 2 b 21.9 3 8(330点数解答 | 2024-01-12 17:20:10)256
- python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 转成 列表 相同的值在一个列表,最终结果 [['a',23.1,1,2],['b',21.9,3,8],](238点数解答 | 2024-01-12 16:16:23)235
- python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 转成 列表 相同的值在一个列表,最终结果 [['a',23.1,1,2],['b',21.9,3,8]](242点数解答 | 2024-01-12 16:16:33)251
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘11月’,‘‘12月’] valueerror: writing 3 cols but got 4 aliases(272点数解答 | 2024-01-12 17:29:05)249
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘12月’,‘‘12月’](451点数解答 | 2024-01-12 17:22:58)256
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘12月’,‘‘12月’] valueerror: length mismatch: expected axis has 3 elements, new values have 4 elements(401点数解答 | 2024-01-12 17:24:16)281
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘12月’,‘‘12月’] valueerror: length mismatch: expected axis has 3 elements, new values have 4 elements(288点数解答 | 2024-01-12 17:24:54)260
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘12月’,‘‘12月’] valueerror: length mismatch: expected axis has 3 elements, new values have 4 elements(286点数解答 | 2024-01-12 17:26:30)242
- python data = {'10月':{'a': 23.1, 'b': 21.9}, '11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}}写入到excel中,自定义表头 [‘产品’,‘10月’,‘‘12月’,‘‘12月’] valueerror: writing 3 cols but got 4 aliases(252点数解答 | 2024-01-12 17:28:47)231
- python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 转成 列表(242点数解答 | 2024-01-12 16:11:44)234
- python data={'10月':{'a':23.1,'b':21.9},'11月': {'a': 1, 'b': 3}, '12月': {'a': 2, 'b': 8}} 转成 列表 相同的值在一个列表(231点数解答 | 2024-01-12 16:12:43)229