介绍
这篇文章给大家分享的是有关Python怎么使用字典实现的简单记事本功能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
Python使用字典实现的简单记事本功能,具体如下:
得到time import 睡眠,strftime 时间=user “Cytus" calendar =, {} def 欢迎(): print 才能“Welcome 用use 却;能够日历只% s" %,用户 print 才能“Calendar  is 开放!” 睡眠才能(1) print 才能strftime (“% A % B % d % Y") print 才能strftime (“% H: % M: % S") 睡眠才能(1) print 才能“What  would 你like 用该怎么办?“ def start_calendar (): 欢迎才能() start 才能=,真的 while 才能开始: ,,,user_choice =, raw_input (“A 用添加、,U 用更新,V 用视图,D 用删除,X 用退出:,“) ,,,user_choice =, user_choice.upper () ,,,if user_choice ==,“V": ,,,,,if len (calendar.keys ()), & lt;, 1: ,,,,,,,print “, calendar is 空!” ,,,,,其他的: ,,,,,,,print 日历 ,,,elif user_choice ==,“U": ,,,,,date =, raw_input (“What 约会吗?,“) ,,,,,update =, raw_input (“Enter 从而更新:,“) ,,,,,日历[日期],=,更新 ,,,,,print “Update 成功!” ,,,,,print 日历 ,,,elif user_choice ==,“A": ,,,,,event =, raw_input (“Enter 事件:,“) ,,,,,date =, raw_input (“Enter  date (MM/DD/YYYY):,“) ,,,,,if (len(日期),祝辞,10),或是int(日期[6:]),& lt;, int (strftime (“% Y")): ,,,,,,,print “invaild 约会!” ,,,,,,,try_again =, raw_input (“Try  ?, Y for 是的,,N for 没有:,“) ,,,,,,,try_again =, try_again.upper () ,,,,,,,if try_again ==,“Y": ,,,,,,,,,继续 ,,,,,,,其他的: ,,,,,,,,,start =False ,,,,,其他的: ,,,,,,,日历[日期],=,事件 ,,,,,,,print “Successfully 添加!” ,,,,,,,print 日历 ,,,elif user_choice ==,“D": ,,,,,if len (calendar.keys ()), & lt;, 1: ,,,,,,,print “, calendar is 空!” ,,,,,其他的: ,,,,,,,event =, raw_input (“What 事件吗?,“) ,,,,,,,for date 拷贝calendar.keys (): ,,,,,,,,,if 日历[日期],==,事件: ,,,,,,,,,,,del 日历(日期) ,,,,,,,,,,,print “Delete 成功!” ,,,,,,,,,,,print 日历 ,,,,,,,,,其他的: ,,,,,,,,,,,print “incorrect event was 指定!” ,,,elif user_choice ==,“X": ,,,,,start =False ,,,: ,,,,,print “invalid 输入!” ,,,,,start =False start_calendar ()
运行结果:
祝辞祝辞祝辞
欢迎使用这个日历。Cytus
日历。2019年8月15日周四
11:25:13
你想做什么?nullPython怎么使用字典实现的简单记事本功能