1 Star 0 Fork 0

liyoujun123 / learning python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
shelveDatabase.py 714 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangming 提交于 2013-08-17 11:09 . new file
#!/usr/bin/env python
#coding: utf-8
import sys, shelve
def storePerson(db):
"""
Query user for data and store it in the shelf object
"""
pid = raw_input('Enter unique ID number: ')
person = {}
person['name'] = raw_input('Enter name: ')
person['age'] = raw_input('Enter age: ')
person['phone'] = raw_input('Enter phone number: ')
db[pid] = person
def lookupPerson(db):
'''
Query user for ID and desired field. and fetch the corresponding data from
the shelf object
'''
pid = raw_input('Enter ID number: ')
field = raw_input('What would you like to know? (name, age, or phone)')
field = field.strip().lower()
print field.capitalize() + ':', \
1
https://gitee.com/liyjLearning/learning-python.git
git@gitee.com:liyjLearning/learning-python.git
liyjLearning
learning-python
learning python
master

搜索帮助