Your code is not very clear. You define a variable cont
with the value 1
and then use a c
variable in a loop (without using range
), but increment it inside the loop .....?
If you know the number of catches you want, put that number inside the cont
variable and do so:
cont = 10
for c in range(cont):
file = 'screenShot{:05d}.jpg'.format(c)
print(file)
Result (see working on Ideone ):
screenShot00000.jpg
screenShot00001.jpg
screenShot00002.jpg
screenShot00003.jpg
screenShot00004.jpg
screenShot00005.jpg
screenShot00006.jpg
screenShot00007.jpg
screenShot00008.jpg
screenShot00009.jpg
The
05d
fault mask used in the
format
call says that the number is integer (
d
), length of 5 characters with 0 on the left (
05
- if using only
5
there will be spaces at left).
That is, your final code looks like this:
import pyscreenshot as ImageGrab
def main():
cont = 10 # Número de capturas
for c in range(cont):
# Desnecessário
# c =+ 1
image = ImageGrab.grab()
image.save('screenShot{:05d}.jpg'.format(c), 'jpeg')
if __name__ == '__main__':
main()