読書の進捗管理するスニペット
ゼミ当日までにテクストを読むペースを計算したくなったのでPythonで関数を作った. 読書家のみなさんのお役に立てたら嬉しい.
from datetime import date def reading_plan(title, total_number_of_pages, period): current_page = int(input("Current page?: ")) deadline = (date(int(period[0]), int(period[1]), int(period[2])) - date.today()).days print(title, period, "まで残り", deadline, "日,", (total_number_of_pages - current_page) // deadline, "p/日")
例えば,『現象学の理念』という本で,ノルマが118ページ,2017年11月15日までに読む必要がある場合
reading_plan("『現象学の理念』", 118, (2017,11,15))
Current page?と聞かれるので現在のページ数を入力すると
Current page?: 1 『現象学の理念』 (2017, 11, 15) まで残り 14 日, 8 p/日
残り日数と,1日のノルマが計算される.