私は現在、ゲームでどれくらいうまくやっているのかに基づいてユーザーがスコアを設定したコードを書いています。誰かが新しいハイスコアを設定して最高の3つを印刷し、他のものを削除してスペースを節約するために、ユーザーのコンピュータにローカルファイルを作成して取得する方法についていくつかの提案をしてもらえますか?ローカルハイスコアを作成するにはどうすればよいですか? - Python
これは現時点で私が持っているコードですが、それは改善の深刻な必要としている:あなたは、コードの用量はまだ何も格納しない見ることができるように
print("Yore score is", score, "/30")
if sthighscore < score:
sthighscore = score
sthighscorename = name
print("NEW 1st HIGH SCORE: ")
print('1: ',sthighscorename, '-', sthighscore)
print("2: ", ndhighscorename, '-', ndhighscore)
print('3: ', rdhighscorename, '-', rdhighscore)
elif sthighscore >= score > ndhighscore:
ndhighscore = score
ndhighscorename = name
print("NEW 2nd HIGH SCORE: ")
print('1: ', sthighscorename, '-', sthighscore)
print("2: ", ndhighscorename, '-', ndhighscore)
print('3: ', rdhighscorename, '-', rdhighscore)
elif ndhighscore >= score > rdhighscore:
rdhighscore = score
rdhighscorename = name
print("NEW 3rd HIGH SCORE: ")
print('1: ',sthighscorename, '-', sthighscore)
print("2: ", ndhighscorename, '-', ndhighscore)
print('3: ', rdhighscorename, '-', rdhighscore)
else:
print("NO NEW HIGH SCORES :(")
print('1: ',sthighscorename, '-', sthighscore)
print("2: ", ndhighscorename, '-', ndhighscore)
print('3: ', rdhighscorename, '-', rdhighscore)
。助けてください。
Pythonでファイル処理に関するいくつかの調査をしましたか? – jonrsharpe
私はあなたが調査することができ、研究を試みたが、私の質問で何も見つけることができなかったかもしれないので、まだこれに新しいです、私は人々が私に何かを教えることができることを願ってここにそれを求めました。 –
これはチュートリアルサイトではなく、あなたの質問はここで間違っています。 [公式チュートリアル](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files)を含む、ファイル処理に関するオンラインチュートリアルがたくさんあります。また、[Python Crash Course](https://www.nostarch.com/pythoncrashcourse/)には、ゲームのハイスコアを保存するセクション(第14章)があります。 –