New paste Repaste Download
#!/usr/bin/env python3
import json
import datetime
import os
def load_notes():
    if os.path.exists("notes.json"):
        with open("notes.json", "r") as f:
            return json.load(f)
    else:
        return []
def save_notes(notes):
    with open("notes.json", "w") as f:
        json.dump(notes, f, indent=4)
def take_note():
    title = input("Enter note title: ")
    content = input("Enter note content: ")
    note = {
        "title": title,
        "content": content,
        "timestamp": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    }
    notes = load_notes()
    notes.append(note)
    save_notes(notes)
    print("Note saved!")
def view_notes():
    notes = load_notes()
    if notes:
        for i, note in enumerate(notes, start=1):
            print(f"\n**Note {i}: {note['title']}**")
            print(f"Timestamp: {note['timestamp']}")
            print(note['content'])
    else:
        print("No notes yet!")
def main():
    while True:
        print("\n1. Take a note")
        print("2. View notes")
        print("3. Quit")
        choice = input("Choose an option: ")
        if choice == "1":
            take_note()
        elif choice == "2":
            view_notes()
        elif choice == "3":
            break
        else:
            print("Invalid option. Try again!")
if __name__ == "__main__":
    main()
Filename: None. Size: 1kb. View raw, , hex, or download this file.

This paste expires on 2026-03-11 10:44:06.082706+00:00. Pasted through web.