我正在处理待办事项应用程序,显然我希望任务在会话之间保持不变。我从来没有写过任何需要数据持久化的东西,而且我发现的模块(peewee,shelf)似乎无法按照我需要的方式工作。
解决这个问题的最佳方法是什么?
这是到目前为止我的程序的样子:
#define class for tasks
class task():
def __init__(self, name, date):
self.name = name
self.date = date
def expand(self): # returns the contents of the task
print(self.name + " is due " + self.date)
#define function to add tasks
def addTask(name, date):
#todo
#persistently ask user for a command that executes a function
def ask():
while True:
arg = input("")
if arg == "add":
addTask(input("What is the task? "),input("When's it due? "),input("What's the category? "))
else:
print("Command not recognized")
ask()