我怎么能把这样的词典列表
[{'a':1}, {'b':2}, {'c':1}, {'d':2}]
Run Code Online (Sandbox Code Playgroud)
进入这样一个单词
{'a':1, 'b':2, 'c':1, 'd':2}
Run Code Online (Sandbox Code Playgroud) 我有一个关于我想要的字典的问题.我的目标是为单个值设置多个键,如下所示:
dictionary = {('a', 'b'): 1, ('c', 'd'): 2}
assert dictionary['a'] == 1
assert dictionary['b'] == 1
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
简单程序:
storyFormat = """
Once upon a time, deep in an ancient jungle,
there lived a {animal}. This {animal}
liked to eat {food}, but the jungle had
very little {food} to offer. One day, an
explorer found the {animal} and discovered
it liked {food}. The explorer took the
{animal} back to {city}, where it could
eat as much {food} as it wanted. However,
the {animal} became homesick, so the
explorer brought it back to the jungle,
leaving …Run Code Online (Sandbox Code Playgroud)