3 Answers
+ 3
Any type of files can be used. You can handle program files, media files, data files and more.
+ 3
To open files you can use with statement:
with open(file, mode) as foo:
...
where file represents the file name (with the dot extension) and mode represents the way of handling the file.
foo is a variable which refers to the file.
To read the file you need to set the mode to "r" if you want to read the file as text, use "rb" if you want to read the file as bytes.
you can then read the file contents using the read method:
with open(file, "r") as f:
content = f.read()
print(content)