Files
Page content

File modes
rwxwrite-only mode; creates a new file, but fails if the file path already exists.r+abadd to a mode for binary files (i.e., rb, wb)ttext mode for file (automatically decoding bytes to Unicode)
Check file existence
def check_file_existence(file_name):
try:
file = open(file_name, 'r')
file.close()
except FileNotFoundError:
print(f"{file_name} does not exist.")