Python 如何在一分钟后打印输出?
我正在编写一个简单的乘法练习代码,经过60秒后,我想打印变量n。n是用户得到的分数;每个正确答案1个,每个错误答案0.5个 以下是迄今为止的代码:Python 如何在一分钟后打印输出?,python,python-3.7,Python,Python 3.7,我正在编写一个简单的乘法练习代码,经过60秒后,我想打印变量n。n是用户得到的分数;每个正确答案1个,每个错误答案0.5个 以下是迄今为止的代码: import time from random import randint print("Welcome to the random digits generator.\n2 numbers will be displayed, one a 2 digit number and one a 1 digit number.\nType ou
import time
from random import randint
print("Welcome to the random digits generator.\n2 numbers will be displayed, one a 2 digit number and one a 1 digit number.\nType out the product of the two as fast as possible.\nIf you do not know it, give it a guess!\n\n")
def game():
n = 0
v1 = randint(1, 9)
v2 = randint(10, 99)
product = v1 * v2
print(v1)
print(v2)
answer = int(input()) or input()
if answer == product:
n = n + 1
print("\nCORRECT!")
time.sleep(1)
print(chr(27)+'[2j')
print('\033c')
print('\x1bc')
game()
if answer != product:
print("\nINCORRECT", product)
n = n - 0.5
time.sleep(1)
print(chr(27)+'[2j')
print('\033c')
print('\x1bc')
game()
game()
您可以使用时间内置模块的睡眠功能
from time import sleep
print('now')
sleep(60)
print('1 minute later')
提示:sleep1将程序延迟1秒。这是否回答了您的问题?