0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

調整さん(https://chouseisan.com/)というサイトが便利でよく使っているのですが、日付ごとに予定を選択する必要があるので、毎週同じ時間の予定の時に楽に書けるコードを用意しました。

ColabなどのPythonの実行環境でこのコードを実行し、指示に従って入力すると、それぞれの日毎の予定が作れます。

...書いてから思ったけど、今はAIがこういうことやってくれそうですね

month = int(input("何月の予定ですか?:")) # 何月か
first_day = int(input("何日から始めますか?:")) # 何日から始めるか
first_day_of_week = int(input("1日は何曜日ですか?\n日曜なら0、月曜なら1、火曜なら2、水曜なら3、木曜なら4、金曜なら5、土曜なら6\nを半角英数字で入力してください。")) # 最初の日が日曜なら0、月曜なら1、...
available_time = []

print("空いている時間を曜日ごとに入力してください。")
print("複数ある場合はカンマ区切りで入力してください。")
print("例:10:00-12:00, 14:00-16:00")
print("空いていない場合は何も入力せず Enter を押してください。\n")

DoW = ["日", "月", "火", "水", "木", "金", "土"]

for w in range(7):
    text = input(f"{DoW[w]}曜日に空いている時間:")
    if text == "":
        times = []
    else:
        text = text.replace("、", ",")
        times = text.split(",")
        # 前後の空白を消す
        times = [t.strip() for t in times]
    available_time.append(times)

end_day = 31
if month == 2:
  end_day = 28
elif month == 4 or month == 6 or month == 9 or month == 11:
  end_day = 30

for i in range(first_day, end_day + 1):
  day = (i + first_day_of_week - 1) % 7
  for j in range(len(available_time[day % 7])):
    print(str(month) + "/" + str(i) + "(" + DoW[day] + ")" + available_time[day][j])
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?