python shell电话本sqlite版
来源:互联网 发布:七天网络成绩查询入口 编辑:程序博客网 时间:2024/06/05 10:33
<span style="font-family:Courier New;font-size:14px;">#-*- coding:utf-8 -*-import sqlite3import osconn=sqlite3.connect('Contact.db')cu=conn.cursor()sql="select count(*) from sqlite_master where type='table' and name='People';"if not conn.execute(sql): createTab=\"""create table People( id int primary key not null AUTOINCREMENT, name text, mobile text, email text, address text, birthday text, qq text );""" conn.execute(createTab)def add(): name=input("name:") mobile=input("mobile:") email=input("email:") address=input("address:") birthday=input("birthday:") qq=input("qq:") sql="insert into People(name,mobile,email,address,birthday,qq) \values('{0}','{1}','{2}','{3}','{4}','{5}');" cu.execute(sql.format(name,mobile,email,address,birthday,qq)) conn.commit()def delete(name): sql="delete from People where name='{0}'" cu.execute(sql.format(name)) conn.commit()def edit(name): passdef view(op): op2=-1 while op2!=0 : sql="select name from People;" cu.execute(sql) rows=cu.fetchall() for row in rows: if op==row[0]: cu.execute("select * from People where name='{0}'".format(row[0])) rows=cu.fetchall() for row in rows: tmpString=\"""name:{0}moble:{1}email:{2}address:{3}birthday:{4}qq:{5}""" print(tmpString.format(row[1],row[2],row[3],row[4],row[5],row[6])) break op2=input("press 'e' to edit,'-' to delete, others to back\t\t") if op2=='-' : delete(op) break elif op2=='e' : edit(op) break else: op2=0 break op=-1while op!=0: print('\n\n') sql="select name from People;" cu.execute(sql) rows=cu.fetchall() for row in rows: print(row[0]) op=input("\ninput name to view detail.press '+' to add,0 to quit\t") if op=='0': op=(int)(op) print('bye') #save() break elif op=='+' :add() else:view(op)</span>
0 0
- python shell电话本sqlite版
- python shell电话本
- python练习题 0 电话本
- python使用CSV实现电话本
- 数组版电话本
- 数组版电话本
- List版电话本
- Map版电话本
- 电话本
- 电话本
- 电话本
- 电话本
- 电话本
- 简易Python电话本(Simple Python Telephone Book)
- python sqlite
- python + Sqlite
- Python SQLite
- 电话本管理系统集合框架版
- 1A. Theatre Square
- 经典漫画讲解HDFS原理
- Unique Paths II
- 对PHP安全有帮助的一些函数
- Linux 2.6内核中新的锁机制--RCU
- python shell电话本sqlite版
- vs2010 切换到vs2013 后丢失MSVCP100D.dll
- 总是为别人着想, 却要独自去疗伤;
- java设计模式 -------- 行为模式 之 策略模式(2)
- http服务器API
- java中匿名内部类
- win8和win8.1升级win10预览版图文教程
- 递归和尾递归(C实现)
- linux c编程问题