二手产品经理

二手产品经理

THIS IS RENO

replit db - 62 days - Learn Python online for 100 days

Record#

  1. Today there is no knowledge point to learn, it is code practice.
  2. Today I need to write a diary program:
    1. Set a password for the program, only the correct password can access it.
    2. 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()


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.