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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you save an image to a different directory

A

name = r”\this\directory\”

with open(name + “.jpg”, “wb) as f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you check if a file exists

A

os.path.exists()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly