thislist = ["apple", "banana", "cherry"]
for x in thislist:
print(x)
x
x是什么意思,遍历为什么不是x=0,x<3?
thislist = ["apple", "banana", "cherry"]
for x in thislist:
print(x)
x
x是什么意思,遍历为什么不是x=0,x<3?
你说的是c语言的语法,python就是这样的,x就是thislist里取出来的每一项
python里的for是基于迭代器的
如果你接触过c#,里面有foreach语法,java里也有增强for循环,python里的for其实等于c#里的foreach
如果你需要x是从0到3,那么需要这样写
for x in range(0,3):