import mss
with mss.mss() as sct:
filename = sct.shot(mon=-1, output='fullscreen.png')
print(filename)
except Exception as e:
print(e, "\n", e.details)
下面是我使用python3.7运行代码时看到的输出。
XGetImage() failed
{'retval': <mss.linux.LP_XImage object at 0x7fc72d567bf8>, 'args': (<mss.linux.LP_Display object at 0x7fc72db7d1e0>, <mss.linux.LP_Display object at 0x7fc72d567950>, 0, 0, 1920, 1080, 16777215, 2)}
如果有帮助,如果我没有捕捉到异常(stacktrace),下面是输出
Traceback (most recent call last):
File "process.py", line 3, in <module>
filename = sct.shot(mon=-1, output='fullscreen.png')
File "/home/f41lurizer/.local/share/virtualenvs/poker-TAtsjijf/lib/python3.7/site-packages/mss/base.py", line 140, in shot
return next(self.save(**kwargs))
File "/home/f41lurizer/.local/share/virtualenvs/poker-TAtsjijf/lib/python3.7/site-packages/mss/base.py", line 129, in save