0

How to add an image in python

10th Apr 2023, 11:11 AM
Aaniya Hashmi
Aaniya Hashmi - avatar
2 Answers
+ 3
On Sololearn you should get your picture somewhere from internet and write it to a .png file. Like this example: import urllib.request # get a picture x = 'https://picsum.photos/300/400/' file = urllib.request.urlopen(x).read() # write to show with open('file.png', 'wb') as f: f.write(file) f.close()
10th Apr 2023, 11:55 AM
Paul
Paul - avatar
10th Apr 2023, 12:19 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar