int对象不可下标
w = w = == 1]Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
w = == 1]
File "<pyshell#28>", line 1, in <listcomp>
w = == 1]
TypeError: 'int' object is not subscriptable
{:5_94:}
你想问什么? 155185 发表于 2023-2-11 20:12
w === 1]
Traceback (most recent call last):
File "", line 1, in
哈哈哈
w = w == 1] 本帖最后由 chinajz 于 2023-2-11 20:57 编辑
以下是可以的:
w = (i for i in w if i == 1)
你的本意是找出变量中1的位置?
print(w.index(1))#从0开始
页:
[1]