遇到問題遍歷元組像這樣一個元組:迭代與字典裏面
t = ('a','b',{'c':'d'})
for a,b,c in t:
print(a,b,c) # ValueError: not enough values to unpack (expected 3, got 1)
for a,b,*c in t:
print(a,b,c) # ValueError: not enough values to unpack (expected 2, got 1)
for a,b,**c in t:
print (a,b,c) # Syntax error (can't do **c)
任何人都知道我可以保存字典值?我想看看a='a', b='b', and c={'c':'d'}
太棒了!謝謝,把它放在列表中,就像我期待的那樣。 – denvaar