简体   繁体   English

如何使用 Python 选择特定列表?

[英]How can I choose specific list with Python?

loc = list(pyautogui.locateAllOnScreen('img.png'))

It returns list like this:它返回这样的列表:

[Box(left=1315, top=509, width=137, height=35), Box(left=455, top=511, width=137, height=35)]

My question is how can I choose just first list or just second list.我的问题是我怎样才能选择第一个列表或第二个列表。 Right now I know how to select only random one with:现在我知道如何 select 只随机一个:

if loc
    loc = choice(loc)

Your example shows just one list.However if you meant tuple or any iterator just go with loc[0] for first and loc[1] for next and so on.您的示例仅显示一个列表。但是,如果您的意思是元组或任何迭代器,则只需 go,其中 loc[0] 为第一个, loc[1] 为下一个,依此类推。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM