-1

I made a for loop to save files in a directory but i would like the name of the file to start with zeros

this is the code that I made

for index, i in enumerate(list):
     im = PImage.fromarray(i)
     im.save(dir + '/' + 'data_' + str(index) +'.tiff')

And now the file names are

data_1.tiff

data_2.tiff

and so on

But I would like them to be

data_001.tiff

data_002.tiff

Aran
  • 45
  • 5

1 Answers1

-1
im.save(dir + '/' + 'data_%03d'%index +'.tiff')
Scott Hunter
  • 48,888
  • 12
  • 60
  • 101