# 输出进度条的图形

```python
# pip install tqdm
from time import sleep
from tqdm import tqdm
# 这里同样的，tqdm就是这个进度条最常用的一个方法
# 里面存一个可迭代对象
for i in tqdm(range(1, 500)):
  # 模拟你的任务
  sleep(0.01)
sleep(0.5)
```

![](https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FQ1lJSmAig3WD7Cu1ZkHY%2Fimage-20210226153502167.png?alt=media\&token=58aa34f1-bc55-48d9-852b-9c13ace7553a)

```python
# pip install alive-progress
from alive_progress import alive_bar
import time
 
# retrieve your set of items
items = range(100)       
 
# declare your expected total   
with alive_bar(len(items)) as bar:  
  # iterate as usual
  for item in items:        
    # process each item
    bar()
    time.sleep(0.1)img
```

![](https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FFN1sgGgJM0d3npYhp8NY%2Fimage-20210226154200184.png?alt=media\&token=77143859-e173-49fc-b71e-e6a78b2bf3bd)
