/ Published in: Python
The os module is to help you deal with any operation dealing with the directory.
- import os
- # todo check for existing file.
- if os.path.isfile('./gradebook.dat'): # check to see if file exists
- data = open('./gradebook.dat', 'rb') # if file exists open, read all data.
- print("The file gradebook.dat was not found.\n")
- print("We will create one....\n")
You need to login to post a comment.