我想让python打印类似“正在加载。。。”,每个句号打印出来与它们之间的睡眠时间0.5秒间隔
实现方法:
#!/bin/env python
# -*- coding:utf-8 -*-
import sys
from time import sleep
def slow(msg,text):
print msg,
for i in text:
print i,
sys.stdout.flush()
sleep(0.8)
return '.'
例如:
#!/bin/env python
# -*- coding:utf-8 -*-
import sys
from time import sleep
def slow(msg,text):
print msg,
for i in text:
print i,
sys.stdout.flush()
sleep(0.8)
return '.'
slow('loginning','...')
结果:
C:\Python27\python.exe E:/python/PyDev/day3/延时.py
loginning . . .
进程已结束,退出代码0