这段代码相对比较简单,通过time.sleep每隔一秒钟让计数器递减即可
#!/usr/bin/env python import time import sys count = 0 while (count < 10): ncount = 10 - count sys.stdout.write("\r%d " % ncount) sys.stdout.flush() time.sleep(1) count += 1
这段代码相对比较简单,通过time.sleep每隔一秒钟让计数器递减即可
#!/usr/bin/env python import time import sys count = 0 while (count < 10): ncount = 10 - count sys.stdout.write("\r%d " % ncount) sys.stdout.flush() time.sleep(1) count += 1