0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonで連番処理をする方法(連続ファイルをバッチ処理する方法)

Last updated at Posted at 2021-05-22

10桁マーカーの連番ファイルを1000ごとに読み込んでいきたい場合は次のように書けばよい.2通りの方法を示す.

single.py
for i in range(1000,9001,1000):
    path1 = "result_%010d" %(i)
    path2 = "result_"+'{0.010d}'.format

ゼロ埋めでなくスペース埋めする場合

path1 = "flow_%10d" %(i)
path2 = "result_"+'{0.10d}'.format

2重のマーカーがあるなら

double.py
for c in range(1,5+1,1):
    for i in range(1000,9001,1000):
        path1 = "result_%1d_%010d" %(c,i)
        path2 = "result_"+'{:1d}'.format+"_"+'{0.010d}'.format

以上!

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?