Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this try/except block handles accessing a high score
- try: # this attempts to open a file
- with open('score.dat', 'rb') as file: # opens score.dat to read
- highScore = pickle.load(file) # set highScore to the loaded file
- except: # if there is no score.dat file, then this creates one. Without this except, the program would crash.
- with open('score.dat', 'wb') as file: # opens score.dat to write
- pickle.dump(highScore, file) # put the highScore (which is 0 if this runs) in the pickle file
Add Comment
Please, Sign In to add comment