New course! Every coder should learn Generative AI!
Try a free lesson0
How to add an image in python
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()