マイコード:Python、私はリーダーボードを作ろうとしていますが、誰かが私を助けることができるテキストファイルに保存されませんか?
ファイル "leaderboard.txtは" ブランクのまま。それらは両方とも同じフォルダに保存されます。
コード:コードの収縮したバージョンで
print ("1: Enter new high score.", "\n","2: Display scores.", "\n","3: Clear scores", "\n","4: Quit")
choice = input("")
while choice != "4":
file = open("leaderboard.txt", "w")
if choice == "1":
score = input("what was your score")
date = input("whats the date")
name = input("whats your name")
file.write(name + ", "+date+", "+score+"\n")
file.close()
choice = input("choice")
elif choice == "2":
f = open("leaderboard.txt", "r")
file_contents = f.read()
print(file_contents)
f.close()
choice = input("choice")
elif choice == "3":
open("leaderboard.txt", 'w').close()
print("erased")
choice = input("choice")
print("program quit")
file.close()
*質問自体に[MCVE] *入れてください。レビュー[尋ねる]。 – jonrsharpe
スクリーンショットの代わりに質問にあなたのコードをコピーしてください – shash678
あなたが開いている/切り捨てて書いてからファイルから読んでみてください! –