Assuming you have an image stored in some format (maybe base 64 string?) already, you can do something like:
n = raw_input("Number of files: ")
image_list = ... # your logic for the image data here
n = int(n)
for i in range(n):
image = open("image" + str(i) + ".jpg", "w")
image.write(image_list[i])
image.close()
For clarification, w
means write to filename
(overwriting its contents). If you want to append to a file instead, use a
.
Edit: removed my wrong explanation on +
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…