[py]py输入判断-字典
来源:互联网 发布:网络潮语大全2016霸气 编辑:程序博客网 时间:2024/06/15 16:27
1.
dict = {'Name': 'Zara', 'Age': 27}#默认返回Noneprint dict.get('Names')#可以自定义返回hiprint dict.get('Names','hi')
2.打印菜单 输入选项判断选项是否合法
import sysdef menu(): print ''' 1,增加 2,删除 3,修改 4,查询 5,显示所有 6,退出程序 ''' op=raw_input("请输入(1/2/3/4/5/6)> ") return opdef txl_add(): print "增加"def txl_error(): print '当前的输入不在选项内,请重新输入'def txl_exit(): sys.exit(0)ops={ '1':txl_add, # '2':txl_delete, # '3':txl_modified, '6':txl_exit,}def main(): while True: op=menu() ops.get(op,txl_error)()
3,连接数据库
dbconfig.py
imoprt MySQLdbdbconfig={ 'host': '192.168.14.132', 'user': 'root', 'passwd': '123456', 'db': 'txl'}conn=MySQLdb.connet(**dbconfig)cursor=conn.cursor()
阅读全文
0 0
- [py]py输入判断-字典
- py字典
- py字典方法
- py的字典
- py
- py
- py
- py
- py
- py
- py
- Py
- py 基本信息输入框 笔记
- py 元组, 列表与字典
- bin2hex.py && hex2bin.py
- web.py (url.py)
- [py]py存放家具
- py学习之路7---判断
- 分享ssd固态硬盘分区装系统全过程!
- 我与python约个会:13.1 函数中的变量
- $.ajax()方法详解
- 待续
- makefile经典教程
- [py]py输入判断-字典
- next数组
- CentOS 安装和配置 Mantis / Linux下修改Mysql的用户(root)的密码
- 通俗易懂的贪吃蛇游戏
- 多线程面试题
- 微信小程序 input 的 type属性 text、number、idcard、digit 区别
- [LeetCode]119. Pascal's Triangle II
- 【笔记+实战】Logistics Regression
- 分治——大整数乘法