私はPython 3を使用しています。ファイルへのリストの書き込み - 見つからないファイル
これは私が書いている過程のスクリプトです。それは名前/誕生日を求めて、その入力を受け取り、それをリストに追加します。リストは別のファイルに書き込まれます。
私はこれに関する研究を行っており、なぜ機能していないのか分かりません。
print("""Enter the name and birthday of the person like this:
Adam 1/29
""")
all_birthdays = [ "none so far" ]
while True:
birthday = input("> ").upper()
if birthday == "":
break
if birthday == "LIST":
print(all_birthdays)
if birthday not in all_birthdays:
all_birthdays.append(birthday)
else:
print("This name/birthday is already known")
birthday_list = open('test.txt','w')
for bday in all_birthdays
birthday_list.write("%s\n" %bday)
SECOND EDIT:
は、ここに私のコードです私は、コードを追加しました(一番下のforループと作成したファイル)。それはうまくいったけど、ファイルをどこにも見つけられないようだ。どんな助け?どうすればそれを見つけて開くことができますか?このラインWriting a list to a file with Python
()への関数呼び出しの括弧がありません。これらの括弧を追加すると、コードはうまく動作します。 – Dartmouth
ダーツマスは 'upper'関数呼び出しを意味します。 – martineau