我想将值附加到字典中的键,其中值实际上是列表.可能有一个列表,或者可能有多个列表.
我正在尝试这样做的当前方式,我尝试添加的新列表只是覆盖了最后一个列表.据我所知,我不能将列表附加到这样的字典:
my_dict.append(my_list))
Run Code Online (Sandbox Code Playgroud)
当前代码互相覆盖:
urls[domain] = [uri, datecreated]
Run Code Online (Sandbox Code Playgroud)
这可能吗?如果是这样,怎么样?
示例结果如下所示
print all keys and values in urls{}:
google.com : ['/helloworld', 2010-04-02], ['/apage/anotherpage', 2015-09-12]
microsoft.com : ['/awebpage', 2009-02-01], ['/bananas', 2015-12-24], ['/anothergreaturi', 205-12-10]
Run Code Online (Sandbox Code Playgroud)