Images and sound Flashcards
(5 cards)
1
Q
Add an image
A
pip install pillow
from PIL import Image
image = Image.open(‘file.jpg’)
image.show()
2
Q
If your getting your image from requests content how can you make sure PIL can read it to your screen
A
from io import BytesIO
img = Image.open(BytesIO(youriamge))
img.show()
3
Q
How do you save an image to a different directory
A
name = r”\this\directory\”
with open(name + “.jpg”, “wb) as f
4
Q
How do you check if a file exists
A
os.path.exists()
5
Q
If you’re creating a database and table in one function, what do you do after you create the database before you make the table?
A
mycursor.execute(“Use cats”)