-2
私は、ユーザが選択した曜日を曜日に変換し、calendar.weekdayを使用しようとしましたが、動作しません私がインターネット上で見つけたものはどれもうまくいきませんので少し助けてもらえます。Python 3.6.1の日付から曜日まで
import calendar
def date(year, month, day):
y = year
m = month
d = day
#take input form the user
print("Vul in welke datum je wil gebruiken")
while 1:
d = int(input("Vul de dag in: "))
m = int(input("Vul de maand in: "))
y = int(input("Vul het jaar in: "))
calendar.weekday(y, m, d)
print(calendar.weekday(y, m, d))
if (calendar.weekday(y, m, d)) == '0':
print("Maandag")
if (calendar.weekday(y, m, d)) == '1':
print("Dinsdag")
if (calendar.weekday(y, m, d)) == '2':
print("Woensdag")
if (calendar.weekday(y, m, d)) == '3':
print("Donderdag")
if (calendar.weekday(y, m, d)) == '4':
print("Vrijdag")
if (calendar.weekday(y, m, d)) == '5':
print("Zaterdag")
if (calendar.weekday(y, m, d)) == '6':
print("Zondag")
問題は、それは私に答えを与えていないということです、別の式がある。最大の問題は、これは私が作ったもの自分で
...ユーザーが日付を記入させることです私は使うべきか、別の問題がありますか?
は答えてくれてありがとう、それはエラーを与える:日付(スペースで区切られた、年、月、日)を書く:02 09 2000 トレースバック(最も最近の呼び出し最後): ファイル "E:/ Python/Weekdag datum probeer.py"、行5、 day = datetime.date(userInput [0]、userInput [1]、userInput [2]) IndexErrorリストインデックスが範囲外です –
私は編集しました。今すぐ仕事が必要です – Hamperfait