|
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.
大概意思懂了,只是print('What is your {0}? It is {1}.'.format(q, a))这句?其中{0}和{1}不是占位符啊,那应该是什么?还有.format(q, a)是什么?为什么这里没有%号,直接是一个点,新人求解
|
|