基本上我想在我的节目中记录高分。我是编码的新手,所以需要一些帮助。我将创建这个基本程序来演示我想要的东西。
import time
name = input("Please enter your name: ")
mylist=["Man utd are the best team","I am going to be a pro typer.","Coding is really fun when you can do it."]
x=random.choice (mylist)
print ("The sentence I would like you to type is: ")
print (x)
wait = input ("Please press enter to continue, The timer will start upon hitting enter!")
start = time.time()
sentence = input("Start typing: ")
end = time.time()
overall = end - start
if sentence == (x):
print ("It took you this many seconds to complete the sentence: %s" % overall)
if overall <= 9:
print ("Nice job %s" % name)
print ("You have made it to level 2!")
我如何能够节省花费的时间,如果有人节省时间,那就获得新的高分?
答案 0 :(得分:0)
您正在寻找一种在程序执行期间保留数据的方法。有很多方法可以做到,但最简单的是just writing to a file。
此外,如果您想使用数据库,请查看SQLite3以获取Python。