python官方文档5.6节,循环的技巧里用了一个zip函数来匹配元素,文档示例如下:
当同时在两个或更多序列中循环时,可以用 zip() 函数将其内元素一一匹配。
questions = [‘name’, ‘quest’, ‘favorite color’]
answers = [‘lancelot’, ‘the holy grail’, ‘blue’]
for q, a in zip(questions, answers):
… print(‘What is your {0}? It is {1}.’.format(q, a))
…
What is your name? It is lancelot.
What is your quest? It is the holy grail.
What is your favorite color? It is blue.
··
但我用zip()函数时遇到了问题:
def fun(str):
print (str)
print (*str)
x,y=zip(