This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# iambusy.py 10秒おきにマウスカーソルが少しだけ動いてスクリーンセーバー起動を阻止する | |
import pyautogui | |
# pyautogui関数を呼び出すたびに1秒待つ | |
pyautogui.PAUSE = 10 | |
pyautogui.FAILSAFE = True | |
print('中断するにはCtrl-Cを押してください') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# 画像をリサイズしてロゴを貼り付ける | |
import os | |
from PIL import Image | |
import re | |
dirname = './chapter17/' | |
os.makedirs('changed', exist_ok=True) | |
new_dirname = './changed' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# 画像をリサイズしてロゴを貼り付ける | |
import os | |
from PIL import Image | |
import glob | |
dirname = './chapter17/' | |
os.makedirs('changed', exist_ok=True) | |
new_dirname = './changed' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/env python3 | |
# excelをcsvに変換 | |
import openpyxl | |
import os | |
import csv | |
# csvを入れるディレクトリを作る | |
csvdir = './csvs' | |
os.makedirs(csvdir, exist_ok=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/rnv python3 | |
# quickWeather 東京と那須と逗子の天気を表示 54行 | |
import json | |
import requests | |
# city番号をリストに。東京、逗子(横浜)、那須(太田原) | |
cities = ['130010', '140010', '090020'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/rnv python3 | |
# quickWeather 東京と那須と逗子の天気を表示 | |
import json, requests, sys | |
# city番号を定義 | |
tokyo = '130010' | |
nasu = '090020' # 大田原 | |
zushi = '140010' # 横浜 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
input_file = open('example.csv') | |
output_file = open('copycsv.csv', 'w', newline='') | |
input_reader = csv.reader(input_file) | |
output_writer = csv.writer(output_file) | |
for i in input_reader: | |
output_writer.writerow(i) | |
output_writer.writerow(str(i)) | |
output_file.close() | |
input_file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# まとめ | |
import openpyxl | |
from openpyxl.utils import get_column_letter, column_index_from_string | |
# Workbookオブジェクトを取得して情報を表示 | |
print('● 開始') | |
wb = openpyxl.load_workbook('example.xlsx') # ワークブック読み込むんでWorkbookオブジェクトを取得 | |
print(f'typeは{type(wb)}、シート一覧は{wb.sheetnames}、アクティブなシートは{wb.active}') | |
print('終了\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# linkcheck.py URLを指定すると、リンクを抽出して、その先が生きてるか確認し、生きていたらDL、死んでたら通知 | |
import sys, requests, bs4, os | |
os.makedirs('webpages', exist_ok=True) # 保存先ディレクトリを作成 | |
# todo 元ページを取得 | |
if len(sys.argv) < 2: | |
print('使い方 linkcheck.py URL') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# 2048.py 勝手に2048を遊ぶ | |
import random | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
# 2048のサイトにアクセス | |
browser = webdriver.Chrome('/usr/local/bin/chromedriver') |
NewerOlder