标签:
我想让python打印类似“正在加载。。。”,每个句号打印出来与它们之间的睡眠时间0.5秒间隔
实现方法:
1
2
3
4
5
6
7
8
9
10
11
|
#!/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 ‘.‘ |
例如:
1
2
3
4
5
6
7
8
9
10
11
12
|
#!/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‘ , ‘...‘ ) |
结果:
1
2
3
4
|
C:\Python27\python.exe E: / python / PyDev / day3 / 延时.py loginning . . . 进程已结束,退出代码 |
标签:
原文地址:http://www.cnblogs.com/opsedu/p/5500305.html