简单todolist,,txt存储,简单的tod
简单todolist,,txt存储,简单的tod
txt存储,简单的todolist功能
# coding=utf-8# 2013/3/18import time,os#显示def showlist(): os.system("cls") print '\\n' + '[ Todo x ' + str(len(todolist)) + '] ' + time.strftime('%Y/%m/%d %H:%M:%S') print '.........................................' j = 0 for line in todolist: print str(j) + '# ' + line j = j+1 print '.........................................'#增加 def additem(text): if len(todolist) > 9: print 'too many lists' else: os.system("cls") todolist.append(text) showlist()#删除 def delitem(no): if no < len(todolist): os.system("cls") del todolist[no] showlist()if __name__ == '__main__': todolist = [] #读取文本数据 filelist = open('todo.txt','r') for line in filelist: todolist.append(line.replace('\\n','')) filelist.close() #显示列表 showlist() #判断输入状态 while True: reply = raw_input() if reply == 'quit':#退出 filelist = open('todo.txt','w') for line in todolist: filelist.write(line+'\\n') filelist.close() break elif reply[0:4] == 'add ': #增加 additem(reply.replace('add ','')) elif reply[0:4] == 'del ': #删除 if len(reply) == 5: delitem(int(reply[4:5])) else: print 'input error' elif reply == 'show': showlist() else: print 'please input show/add/del/quit'#该片段来自于http://byrx.net
相关内容
- 使用WSDL登陆Netscaler取得设备状态数据,wsdlnetscaler,nag
- MD5,,/*必须在导入pytho
- python版的srt2ass,可以将srt字幕文件转换为ass字幕文件,
- 简单的chain stub,简单chainstub,常用doctest,但是
- 微信公众平台接口Python使用样例,python样例,微信公众平
- 简单的猜数字游戏(无重复数字),猜数字游戏重复数
- 查询日志过去一分钟的并发,日志一分钟并发,该脚本作
- 随即生成生日以及格式,生成生日格式,生成从N年前到
- 抓取douban验证码,douban验证码,# Grab captc
- 30行代码写一个计算器,30行代码写计算器,看了70行代码
评论关闭