0

I have this code:

async with aiohttp.get('http://httpbin.org/image/png') as r:
            if r.status == 200:
                img = await r.read()
                with open('Images/' + 'img.png', 'wb') as f:
                    f.write(img)
                    print('Done downloading!')

There seems to be a problem. The code works fine but when I try to download another image and if it has the same filename then it will replace the old image with the new one. I don't want it to do this which is why I need to know of a a way to check for duplicates and try to rename the second one but keep the first one the same if they both have the same filename.

0 Answers0