"""
# Case A: When initiating the dict with all keys and values \
# announced explicitly, \
# both tuple and list.append will work correctly."""
# value type is tuple
a ={"1":(),"2":()}
a["1"]+=(0,)print(a)
# Output
{'1':(0,),'2':()}
# value type is list
b ={"1":[],"2":[]}
b["1"].append(0)print(b)
# Output
{'1':[0],'2':[]}"""
# Case B: When initiating the dict with dict.fromkeys, \
# tuple changes only the key as we announce,
# while list.append will change all keys' values unexpectedly."""
# value type is tuple
c = dict.fromkeys(["1","2"],())
c["1"]+=(0,)print(c)
# Output
{'1':(0,),'2':()}
# value type is list
d = dict.fromkeys(["1","2"],[])
d["1"].append(0)print(d)
# Output
{'1':[0],'2':[0]}
小结:如果手动定义Key和初始Value,那么,无论使用tuple还是list.append,都不会混淆;如果使用dict.fromkeys()定义Key和初始Value,那么,使用list.append会改变所有key的value,使用tuple不会。"""// Case A: When initiating the dict with all keys and values ann...