问题描述
当我运行以下代码段时,我收到一条错误消息,指出下面的代码可以有人解释这一点,因为经过一个小时的研究,我找不到有人遇到相同的问题 init .py文件似乎有问题,但这也许只是我的代码。屏幕应搜索的所有图像文件都保存在我桌面上的文件中,以使它们的路径变得很短
import pyautogui
import time
import keyboard
import random
import win32api,win32con
i = 1
while i < 5:
if pyautogui.locateOnScreen('NEXT(1000)') !=None:
print("Base has been found")
if pyautogui.locateOnScreen('triple 7s(go)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('triple 7s(el)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('single 6(go)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('double 5s(both)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('single 8(go)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('single 9(el)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('single 6(el)',confidence=0.95):
i = 6
elif pyautogui.locateOnScreen('single 8(el)',confidence=0.95):
i = 6
else:
click(-97,576)#use (importpygui)/(pyautogui.displayMousePosition)
else:
time.sleep(0.5)```
```
Traceback (most recent call last):
File "C:\Users\astro\OneDrive\Desktop\STENCILS\Python bots\Clash of Clans auto Base Finder.py",line 11,in <module>
if pyautogui.locateOnScreen('NEXT(1000)') !=None:
File "C:\Users\astro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyautogui\__init__.py",line 175,in wrapper
return wrappedFunction(*args,**kwargs)
File "C:\Users\astro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyautogui\__init__.py",line 213,in locateOnScreen
return pyscreeze.locateOnScreen(*args,**kwargs)
File "C:\Users\astro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\__init__.py",line 360,in locateOnScreen
retVal = locate(image,screenshotIm,line 340,in locate
points = tuple(locateAll(needleImage,haystackImage,**kwargs))
File "C:\Users\astro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\__init__.py",line 197,in _locateAll_opencv
needleImage = _load_cv2(needleImage,grayscale)
File "C:\Users\astro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyscreeze\__init__.py",line 160,in _load_cv2
raise IOError("Failed to read %s because file is missing,"
OSError: Failed to read NEXT(1000) because file is missing,has improper permissions,or is an unsupported or invalid format```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)