Created
April 2, 2022 13:13
-
-
Save sephii/a2aaeb7b0c10ebaaebb5490990fddbf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_visit(): | |
try: | |
with open("counter.txt", "r") as fp: | |
counter = int(fp.read()) | |
except (IOError, ValueError): | |
counter = 0 | |
counter = counter +1 | |
with open("counter.txt", "w") as fp: | |
fp.write(str(counter)) | |
return counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment