Skip to content

Commit 8eb5019

Browse files
committed
提交代码
1 parent 6a877d4 commit 8eb5019

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

xianhuan/tqdm/tqdmdemo.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: 闲欢
5+
"""
6+
7+
from tqdm import tqdm
8+
from time import sleep
9+
from tqdm import trange
10+
11+
for char in tqdm(['h', 'e', 'l', 'l', 'o']):
12+
sleep(0.25)
13+
14+
for i in tqdm(range(100)):
15+
sleep(0.05)
16+
17+
for i in trange(100):
18+
sleep(0.05)
19+
20+
pbar = tqdm(range(5))
21+
for char in pbar:
22+
pbar.set_description("Progress %d" %char)
23+
sleep(1)
24+
25+
26+
with tqdm(total=100) as pbar:
27+
for i in range(1, 5):
28+
sleep(1)
29+
# 更新进度
30+
pbar.update(10*i)
31+
32+
with tqdm(total=100, colour='yellow') as pbar:
33+
for i in range(1, 5):
34+
sleep(1)
35+
# 更新进度
36+
pbar.update(10*i)
37+
38+
39+
for i in trange(3, desc='outer loop'):
40+
for i in trange(100, desc='inner loop', leave=False):
41+
sleep(0.01)
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+

0 commit comments

Comments
 (0)