求python技术宅大神帮助..python 数据库编写 写一个类似联络人信息数据的数据库。。。 60
求帮忙。。。。TOT教授坑爹完全不懂就要交作业了。。。。求大神帮忙。。有会的么。。泪奔。。写一个文字的朋友信息的简单数据库。。谢过了TaT...
求帮忙。。。。TOT
教授坑爹完全不懂就要交作业了。。。。
求大神帮忙。。有会的么。。泪奔。。写一个文字的朋友信息的简单数据库。。谢过了TaT 展开
教授坑爹完全不懂就要交作业了。。。。
求大神帮忙。。有会的么。。泪奔。。写一个文字的朋友信息的简单数据库。。谢过了TaT 展开
3个回答
2013-04-08 · 知道合伙人软件行家
关注
展开全部
# addressbook.py
# SIMPLE ADDRESS BOOK
# data stored in addressbookdata
# Justin Seiser 10/5/08
def search_database ():
#search algoritm
searchcriteria = raw_input("What do you want to search by? ")
temp1 = open("addressbookdata","r")
for line in temp1:
if searchcriteria in line:
print ("\n")
print line
print ("\n")
else:
print "Search yeilded zero results"
def append_to_database (info):
# append the info list to file
temp1 = open("addressbookdata","a")
temp1.write(info)
temp1.write("\n")
print ("The record was added to the database address book ")
def collect ():
# collect information...
# append_to_file ([lastname, firstname]) # etc...
lastname = raw_input("What is the persons last name? ")
firstname = raw_input("What is the persons first name? ")
phone = raw_input("What id the persons phone number? ")
email = raw_input("What is the persons email address? ")
address = raw_input("What is the persons address? ")
info = (firstname + " " + lastname + ", " + phone + ", " + email + ", " + address)
append_to_database (info)
def menu ():
answer = raw_input("Are You Creating An Entry [Press 1] \nOr Are You Searching An Entry [Press 2] ")
# ask user what to do
if answer == "1":
collect ()
if answer == "2":
search_database()
else:
print str(answer) + " is not a valid option, try again"
menu()
# start everthing:
menu ()
# SIMPLE ADDRESS BOOK
# data stored in addressbookdata
# Justin Seiser 10/5/08
def search_database ():
#search algoritm
searchcriteria = raw_input("What do you want to search by? ")
temp1 = open("addressbookdata","r")
for line in temp1:
if searchcriteria in line:
print ("\n")
print line
print ("\n")
else:
print "Search yeilded zero results"
def append_to_database (info):
# append the info list to file
temp1 = open("addressbookdata","a")
temp1.write(info)
temp1.write("\n")
print ("The record was added to the database address book ")
def collect ():
# collect information...
# append_to_file ([lastname, firstname]) # etc...
lastname = raw_input("What is the persons last name? ")
firstname = raw_input("What is the persons first name? ")
phone = raw_input("What id the persons phone number? ")
email = raw_input("What is the persons email address? ")
address = raw_input("What is the persons address? ")
info = (firstname + " " + lastname + ", " + phone + ", " + email + ", " + address)
append_to_database (info)
def menu ():
answer = raw_input("Are You Creating An Entry [Press 1] \nOr Are You Searching An Entry [Press 2] ")
# ask user what to do
if answer == "1":
collect ()
if answer == "2":
search_database()
else:
print str(answer) + " is not a valid option, try again"
menu()
# start everthing:
menu ()
展开全部
有具体要求么?真要写数据库?
我擦,数据库写出来这还叫平时作业?毕业设计都绰绰有余了吧
我擦,数据库写出来这还叫平时作业?毕业设计都绰绰有余了吧
追问
是个小作业。。。但是有一堆零零散散的要求。。。
给了一个CSV的数据库,貌似要代入。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是使用数据库还是写数据库?有两种简易数据存储可以考虑
1、CSV
2、XML
1、CSV
2、XML
追问
有个给定的CSV数据....
追答
给定了CVS文件,那么说来就是使用CVS作为数据源,也许需要再增加索引、主键等功能,可构成简单的文件型数据库。
如果还需要有结构化查询能力,那就要使用正则表达式分拆命令与数据,再调用相应的 CRUD 函数处理。
前面 luotuo512 已贴出代码,可实现非结构化的数据库能力,值得参考。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询