im trying to make a simple web crawler which runs through a url and downloading the images from it and the url starts with “url.com/img0001.png” but the 0s are being removed and just showing img1.png
how would i go around keeping the zeros
current = 0001
while True:
url = "https://url.com/{a}.png"
current = current + 1
print(url.format(a = current))
First, when you say current = 0001, it’s the same than current = 1. They are the same number. I think you are looking for a strict 0001, so you may have to use strings instead, something like current = "0001". The issue is that you’ll have figure out a way to modify current, since current = current + 1 won’t work now.
How you format a number (leading zeros, scientific notation, significant figures) isn’t intrinsic to the number itself, but something you specify when converting the number to a string.