我只是在弄乱,我想打印“加载栏”。我想说"Calculating..."
,每个.
在每1秒后加到Calculating
。我正在使用end=''
将点保持在同一行上,但不是等待1秒钟然后添加每个句点,而是等待3秒并总共打印"Calculating..."
。
import time
dividend = input("Enter number to be divided: ")
divisor = input("Enter divisor: ")
dividend = float(dividend)
divisor = float(divisor)
wholenum = dividend // divisor
remainder = dividend % divisor
print("Calculating", end='')
time.sleep(1)
print(".", end='')
time.sleep(1)
print(".", end='')
time.sleep(1)
print(".")
time.sleep(1)
print("The quotient is:", wholenum)
print("The remainder is:", remainder)
在打印语句中使用flush=True
。
print(".", end='', flush=True)