プログラミングBlog

勉強会㉑

勉強会

今週はLT会お休みで普通のもくもく会してました。

Pythonの実行環境を揃える

Anaconda install

Pythonディストリビューション
www.anaconda.com

PyCharm install

IDE www.jetbrains.com

やったこと

Pythonのパッケージ管理システムでライブラリをinstall
pyautogui ・・・キャプチャを撮ったり、マウス操作ができるライブラリ

pipコマンド

pip install pyautogui

キャプチャの撮り方

import pyautogui

screenshot = pyautogui.screenshot()
screenshot.save('キャプチャ.png')

キャプチャ画像読み込み

from PIL import Image

img = Image.open('スクリーンショット.png')
img.show()

1秒間停止

import time

time.sleep(1)

完成したコード

import pyautogui
import time
from PIL import Image

num = 0
sc = pyautogui.screenshot()

while True:
    if num == 10:
        break
    print(num)
    sc.save(f'スクリーンショット{num}.png')
    img = Image.open(f'スクリーンショット{num}.png')
    img.show()
    num += 1
    time.sleep(1)

print('finish')