我正在尝试使用 python pycharm 编写自动屏幕截图程序,但它不起作用。我已经通过终端检查并升级了我的 pip 和 pyautogui,但它仍然无法工作。有人可以帮助我吗?
Import pyautogui
im = pyautogui.screenshot('screenshot.png')
print(pyautogui.__version__)
这是错误的屏幕截图
该错误通常表明您正在尝试在字符串和整数之间执行某种算术或比较操作,这在库中是不允许的,因此,请尝试我的选项。祝你好运!!!
import pyautogui
print(pyautogui.__version__) #print the version
screenshot_path = 'screenshot.png' #take a screenshot
im = pyautogui.screenshot(screenshot_path)
print(f'Screenshot saved at: {screenshot_path}')
#terminal --run
pip install pillow
# main code
import pyautogui
screenshot_path = '/path/to/save/screenshot.png'
# try it later, if code does not work
# im = pyautogui.screenshot("screenshot_path")
im = pyautogui.screenshot(screenshot_path)