Record#
- Today there is no knowledge point to learn, it is code practice.
- Today I need to write a diary program:
- Set a password for the program, only the correct password can access it.
- After accessing, you can add/view diaries.
CODE#
from replit import db
import os, datetime
correctPassword = "1"
def add(t):
db[timestamp] = t
def view():
journal = db.keys()
show = "n"
for key in journal:
if show.lower() == "n":
print(f"{key}: {db[key]}")
elif show.lower() == "e":
break
show = input("Next or Exit? > ")
passwordEntered = input("Password? > ")
if passwordEntered != correctPassword:
exit()
else:
while True:
os.system("clear")
menu = input("Welcome\n1: Add\n2: View\n")
if menu == "1":
timestamp = datetime.datetime.now()
print(timestamp)
add(input("> "))
elif menu == "2":
view()