File I/O Flashcards

1
Q

What does I/O stand for?

A

Input something from the outside world

Output something to the outside world

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

One of the most common ways we us I/O is

A

to read / write files

example of using I/O: we develop a script to compress images

we need to INPUT IMAGE
and OUTPUT COMPRESSED IMAGE

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

What is Open?

A

Python’s built-in function that allows us to open and write to files

example of what we can do:

open(‘name of file’)

you have to manually close the file after you are finished with the file

open has a default param, mode. It is set to ‘r’ for read. Can be changed to ‘w’ for write or ‘r+’

most common modes are:
read, write, and append

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

File I/O errors

A

common pattern when working with File I/O is to put them in a Try Except block

try:
code
except FileNotFoundError:
code

or..

except IOError:

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