Visitor Trends
Today
Yesterday
Total
Popular Posts
Latest Posts
Fresh thoughts and recent updates from the blog
tistory view
728x90
반응형
모듈 설치
pip install tqdm
사용법
from tqdm import tqdm
for i in tqdm(range(100)):
# some code
pass
위와 같이 사용할 수 있으며, tqdm(range(N)) 은 trange 로 줄여서 사용할 수도 있다.
사용 예시
from tqdm import trange
from time import sleep
for i in trange(100):
sleep(0.1)
# 출력 결과
# 100%|█████████████████████████████████████████████████████████████████████| 100/100 [00:10<00:00, 9.46it/s]
아래 이미지는 위 코드를 실행했을 때 나타나는 결과임.

CLI 사용 예시
Python 스크립트 뿐만 아니라 CLI 으로도 사용 가능하다.
아래 예시는 시간이 아닌 bytes 값으로도 progress 추적이 가능토록 한다.
$ seq 9999999 | tqdm --bytes | wc -l
75.2MB [00:00, 217MB/s]
9999999
$ tar -zcf - docs/ | tqdm --bytes --total `du -sb docs/ | cut -f1` \
> backup.tgz
32%|██████████▍ | 8.89G/27.9G [00:42<01:31, 223MB/s]
출처
GitHub - tqdm/tqdm: :zap: A Fast, Extensible Progress Bar for Python and CLI
:zap: A Fast, Extensible Progress Bar for Python and CLI - GitHub - tqdm/tqdm: :zap: A Fast, Extensible Progress Bar for Python and CLI
github.com
기타 의견
개인적으로 PoC 실행했을 때 진행률을 나타내주면 정말 친절한 PoC 가 될 것 같은 생각이 듬.

728x90
반응형
'Dev > Python' 카테고리의 다른 글
| [python] 현재 디렉토리에 있는 이미지파일 목록 리스트로 가져와서 읽기 (0) | 2024.06.27 |
|---|---|
| [pymongo] pymongo MongoClient 데이터베이스, 컬렉션명 출력하기 (0) | 2024.06.26 |
| python3.x 원하는 버전의 pip 설치하기 (0) | 2023.09.01 |
| [mongoDB] 맥북에 몽고DB 설치하는 방법 (1) | 2023.07.14 |
| [pandas] dataframe에 있는 컬럼들을 딕셔너리로 새컬럼 생성하기 (1) | 2023.06.30 |
Comments