我正試圖在屏幕上查找對象,看看它們是否存在,如果有,請選擇它們。使用Sikuli庫運行這個小自動化。從多個變量中選擇
while True:
if exist("image/one.png", "image/two.png", "image/three.png"):
click ("image/one.png", or "image/two.png", or "image/three.png")
break
我得到一個SyntaxError: mismatched input 'or' expecting RPAREN
我做了一個快速的搜索,但沒有什麼,我看到有關我的具體問題。
我甚至試過
while True:
if exist("image/one.png", or "image/two.png", or "image/three.png"):
click ("image/one.png", or "image/two.png", or "image/three.png")
break
而這導致了同樣的錯誤。
@Stephan:錯誤的新代碼片段。
class gameImages():
imageFiles = ["one.png", "two.png", "three,png"]
for imageFile in imageFiles:
if exists(imageFile):
click(imageFile)
現在的錯誤,:
NameError: name 'imageFiles' is not defined
你爲什麼把這些'或'放入?你不能在逗號後面加上'或'。你從事什麼樣的工作? –
如果您用'|'替換'或',該怎麼辦? – refi64
@DavidRobinson我看到之前做過的事情,不記得在哪裏。你是說刪除逗號,它應該起作用嗎? – Dave