第 4步:现在我们准备开始编写get_high_scores()

您可以使用open()命令在 Python 中打开文件。这就像单击一个文件,但带有代码!

open()第二个参数是我们访问文件的模式。 "r"表示我们正在阅读,但不编辑它。

  • 在主题中,单击并在get_high_scores()中拖动Open in Read Mode
  • 然后,将"my_file.txt"更改为file_name

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)