LoginSignup
0
1

More than 3 years have passed since last update.

python tips

Posted at

f'{:.2f}'

f'{}'を使いつつ有効数字を指定して表示したい時はこう

tqdm を使う

進捗管理をしたい時はtqdmを使いましょう。
tqdmについての基本的なことは、他の記事できれいにまとまっているのでそちらを参照してください。
「とりあえずtqdmで囲ってるけど…」を脱したい人向けです。

ind=3
txt = f'{ind:3d}.npy'

メッセージを表示する

pbar = tqdm(lis)
for something in pbar:
    pbar.set_description("Processing %s" % something)

が基本です。自分は、pathlibを使うことが多いので、

from pathlib import Path
path = Path('hoge')
objects = path.glob('*/hoge')
pbar = tqdm(objects)
for object in pbar:
    pbar.set_description("Processing %s" % object.name)

などとすることで今処理しているファイルの名前を表示することができます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1