安裝套件:
截取整個螢幕,儲存為 png 檔案:
截取螢幕指定區域,儲存為 png 檔案:
文章撰寫中...請稍後...
參考資料:
pip install mss
截取整個螢幕,儲存為 png 檔案:
import mss
with mss.mss() as sct:
filename = sct.shot(output="screenshot.png")
截取螢幕指定區域,儲存為 png 檔案:
import mss
with mss.mss() as sct:
region = {"top": 100, "left": 100, "width": 300, "height": 200}
screenshot = sct.grab(region)
mss.tools.to_png(screenshot.rgb, screenshot.size, output="partial_screenshot.png")
文章撰寫中...請稍後...
參考資料:
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com