Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 字典:使用已转换为字符串的列表项将2个值集成到一个键_Python_Json_String_Dictionary - Fatal编程技术网

Python 字典:使用已转换为字符串的列表项将2个值集成到一个键

Python 字典:使用已转换为字符串的列表项将2个值集成到一个键,python,json,string,dictionary,Python,Json,String,Dictionary,我正在尝试将一本词典集成为另一本词典的键。同时,我尝试使用下面的代码使用列表(a)中的第二个值扩展python字典的键('day')值对: dictionary = [{'day': int(a[1]), 'year': (a[2])}] big_dictionary['sub_dictionary'] = dictionary dictionary['day'].extend(int(a[6])) 我收到以下错误消息:“T

我正在尝试将一本词典集成为另一本词典的键。同时,我尝试使用下面的代码使用列表(a)中的第二个值扩展python字典的键('day')值对:

dictionary = [{'day': int(a[1]),
                      'year': (a[2])}]

big_dictionary['sub_dictionary'] = dictionary
            dictionary['day'].extend(int(a[6]))
我收到以下错误消息:“TypeError:列表索引必须是整数或片,而不是str;” 因此,我尝试将添加的值转换为字符串。但是我收到了同样的打字错误。
有人有解决方案吗?

字典
不是字典,它是一个字典列表,
字典[0][“day”]
是一个整数,不能扩展。谢谢!那么,在扩展之后是否可以转换为int?请提供一个输出的示例。