我一直在研究“Learn Python the Hard Way”,到目前为止进展顺利,但我有几个问题:
the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
for number in the_count:
print "This is count %d" % number
# same as above
for fruit in fruits:
print "A fruit of type: %s" % fruit
# also we can go through mixed lists too
# notice we have to use %r since we don't know what's in it
for i in change:
print "I got %r" % i
在这些 for 循环中,“number”、“fruit”和“i”分别是什么词重要吗?感觉就像 python 中的所有东西都需要定义,但如果这有意义的话,我们从来没有真正“定义”过数字。我不确定如何正确表达这个问题=/