简单记事本逻辑
eventlist=[]
def genEvent():
'return event'
event={}
keys = ['时间','地点','事件']
for key in keys:
msg = input(f'enter {key}')
event.setdefault(key,msg)
return event
def addEventToMemo():
c = genEvent()
eventlist.append(c)
listEvent()
def listEvent():
for item in eventlist:
print(item)
def pointfunc():
print('input support a/l')
def startRun():
opt_dict={'a':addEventToMemo,'l':listEvent}
tips = {'a:': 'Add event','l:':'List Event'}
for k,v in tips.items():
print(k,v)
while True:
cmd = input('Enter Cmd a/l/q:')
if cmd == 'q':
print('exit')
break
func= opt_dict.get(cmd,pointfunc) #get返回结果None 赋值给函数
func()
if __name__ == '__main__':
startRun()