我想将列表值追加到字典中的一个键上,其中这些值实际上是列表。可能有一个列表,也可能有多个列表。
我目前尝试的方法是,我尝试添加的新列表只会覆盖上一个列表。据我所知,我也无法像这样将列表附加到字典中:
我目前尝试的方法是,我尝试添加的新列表只会覆盖上一个列表。据我所知,我也无法像这样将列表附加到字典中:
my_dict.append(my_list))
当前会相互覆盖的代码:
urls[domain] = [uri, datecreated]
这是可能的吗?如果可以,怎么做呢?
示例结果将会像这样:
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]