简体   繁体   中英

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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