- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用以前版本的 pyautogui,当找不到图像时,返回的是“None”,所以我用 except TypeError:
来处理它。但是自更新(版本 0.9.41)以来,它无法正常工作,因为它返回 ImageNotFoundException,但未被识别为异常。当我尝试执行 except ImageNotFoundException:
时出现错误:
[E0712] Catching an exception which doesn't inherit from Exception: ImageNotFoundException
应该如何处理这个错误?
最佳答案
这适用于 pyautogui 0.9.52
和 python 3.9.0
import pyautogui
# force use of ImageNotFoundException
pyautogui.useImageNotFoundException()
try:
location = pyautogui.locateOnScreen('foo.png')
print('image found')
except pyautogui.ImageNotFoundException:
print('ImageNotFoundException: image not found')
我在此页面中找到了 useImageNotFoundException()
部分 locateCenterOnScreen doesn't raise ImageNotFoundException. · Issue #441 · asweigart/pyautogui .如果未调用 useImageNotFoundException()
,locateOnScreen()
只会返回 None
。
关于Python PyAutoGUI 返回 "ImageNotFoundException",但 "except"不将其识别为异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54461133/
使用以前版本的 pyautogui,当找不到图像时,返回的是“None”,所以我用 except TypeError: 来处理它。但是自更新(版本 0.9.41)以来,它无法正常工作,因为它返回 Im
我正在尝试将 visual studio 代码覆盖率文件 (data.coverage) 导出到 xml,如 this blog post from the code analysis team 中所
我正在个人项目中试用 Microsoft Graph 以了解它。我在 Azure 中注册了一个应用程序和 secret 。此应用程序在应用程序级别包含以下权限:User.Read.All、User.R
我是一名优秀的程序员,十分优秀!