请教各位,'float' object is not subscriptable 的问题出在哪里啊
list_001 =for num1 in range(1, len(list_001)):
k1 = list_001
k2 = list_001
print(num1)
print(k1)
print(k2)
运行结果报错是
File "C:\Python_3.6\Python_File_Py\EX_001\range_print.py", line 4, in <module>
k1 = list_001
TypeError: 'float' object is not subscriptable
请教大家应该怎么改正啊
for num1 in range(len(list_001)):
k1 = list_001
k2 = list_001
print(num1)
print(k1)
print(k2) 不知道你想要輸出哪裡一種結果:
以下兩種,有可能其中一種是你要的
list_001 =
for i, num1 in enumerate(list_001):
k1 = list_001
k2 = list_001
print(num1)
print(k1)
print(k2)list_001 =
for i in range(0, len(list_001), 2):
k1 = list_001
k2 = list_001
print(i)
print(k1)
print(k2)
num1在这里是1~25,如果要遍历list_001 直接for num1 in list_001就可以了。如果是要访问第N个元素list_001
页:
[1]