How to add an image in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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