【发布时间】:2021-07-18 00:53:55
【问题描述】:
每次 dataValue 等于数据时,我都会尝试获取列表编号。我想获得将在数据变量的 [] 中显示的数字。这可能吗?
for x in data:
if dataValue == x:
#gets the current array number and stores it
【问题讨论】:
-
通常的用法是
for index, x in enumerate(data):-index是您要查找的号码。 -
您似乎正在寻找
index方法。请参阅您的列表教程。my_store = data.index(x).
标签: python arrays list for-loop