Skip to content

Instantly share code, notes, and snippets.

@sephii
Created April 2, 2022 13:13
Show Gist options
  • Save sephii/a2aaeb7b0c10ebaaebb5490990fddbf1 to your computer and use it in GitHub Desktop.
Save sephii/a2aaeb7b0c10ebaaebb5490990fddbf1 to your computer and use it in GitHub Desktop.
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