主要目标:从文本文件中读取最高分的功能。要传递给函数的参数:一个文本文档!
def highscore():
try:
text_file = open ("topscore.txt", "r")
topscore = int(text_file.read())
print topscore
text_file.close()
return topscore
except:
print "Error - no file"
topscore = 0
return topscore
如何添加文本文件作为参数?