我想要完成的是第一个文本在 1 秒后出现。然后 2,等等。直到 10。然后当时间等于 10 时,时间减少,所以文本在 9 秒后出现,然后是 8 等等。
如何修复此代码以使其正常工作?
错误:
Traceback (most recent call last):
File "C:/Users/Eric/Dropbox/time.py", line 13, in <module>
time.sleep(time)
AttributeError: 'int' object has no attribute 'sleep'
编码 :
import time
x = 1
t = 1
time = t + 1
while x == 1:
print time
if time >=10:
time = t - 1
elif time <= 0:
time = t + 1
time.sleep(time)
编辑:
import time
x = 1
t = 1
time1 = 0
while x == 1:
if time1 == 10:
time1 = time1 - 1
elif time1 == 0:
time1 = time1 + 1
else :
time1 = time1 + 1
print time1
time.sleep(time1)
所以我改变了程序,所以我几乎可以正常工作。它的作用是计数到 10,然后计数到 9,然后返回到 10。例如。1,2,3,4,5,6,7,8,9,10,9,10,9,10 我如何设置它以便程序将时间增加到十然后减少到零然后再次增加?