可以问一道关于python的题吗?题目是write a program to keep track of conference attendeesfor each attendee,your program should keep track of name,company,state,mail.it should allow user to do things :add a new attendee,display info on a att

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 01:11:53
可以问一道关于python的题吗?题目是write a program to keep track of conference attendeesfor each attendee,your program should keep track of name,company,state,mail.it should allow user to do things :add a new attendee,display info on a att
xV[kG+aw*.}]P0} #HZZM1qCrSǹcRFE\v%*PJ 9ߜeӵ{հ-48l$- 0 3DBB$. ZCU#APB%(CW%צd|7IJ!9. &'R<}B'LZR$^P稈]`z\>n#/QD`k J4E|" 2 (+"[J{$ghԽE e^2Ɖ | ʈ ZO Vn{YfǏ:۝;'N>|yTS,YBΒە>3o<5^ٌ_.-璟䕃O(X!9B $XDoŰ,K_ay@EgFKRF{P&M꒚ ,7F?/~1{͐2B"\,0*yTP*J|j˵tAB,y!,yB#Û7c:FIj^)sݧ#jɃ;^Y>7EV(  " {ҁXCiʁ0cO3iEN)i@ۗi5d|"UAJ0B[Aj.5-sMM& d5)]C`3fCPܠf!i`! Ǚ #x D "Q }91cT :l9YU8%ÏdjKFۦb 9< B<Et]F8ϰ9KbG7|q)8Q_Yq”%I[0C=<?O<3Mrt/ykt|s ^HDj@@Hǜ^5SB_c8t3 񻯠?[l nʑF^JL+ %dPT@@Rj (QƹJ{yw c݇~5Q0ȵ-}txBqۆ'+KN|kzπm篴M|eߜ2~~F*A 'Һi1l8IףRʛzG7''{Cwn=9.QxTGJcH(7$tn̜ժXZows nn U>rguZ`Yń,񼺟 $W$4a50֥3Q>(ZJkN>Ho&jjؓbH$p\F˲rY&eSi1VG^[

可以问一道关于python的题吗?题目是write a program to keep track of conference attendeesfor each attendee,your program should keep track of name,company,state,mail.it should allow user to do things :add a new attendee,display info on a att
可以问一道关于python的题吗?题目是write a program to keep track of conference attendees
for each attendee,your program should keep track of name,company,state,mail.it should allow user to do things :add a new attendee,display info on a attendee,delete an attendee ,list the name and mail of all attendees,and list the name and mail from a given state.the attendee should be stored in a file and loaded when the program starts.这个不用界面也可以吗?思路是怎么样的.因为是初学者,所以希望能帮个忙

可以问一道关于python的题吗?题目是write a program to keep track of conference attendeesfor each attendee,your program should keep track of name,company,state,mail.it should allow user to do things :add a new attendee,display info on a att
#!sur/bin/env python
'''
Copyright (C)2012
@authored by tws
last modefied at 2012/12/2 23:52
'''
import pickle,os
data = []
filename = os.getcwd() + os.path.sep + 'data' #文件保存路径
def main():
global data #存放数据的列表
data = load()
string = '''
(A)dd new
(D)ispaly
(R)emove
(S)how all
(L)ist
(Q)uit
'''
while True:
action = input(string)
if action in 'Aa':
add()
elif action in 'Dd':
Display()
elif action in 'Rr':
Remove()
elif action in 'Ss':
Show()
elif action in 'Ll':
List()
elif action in 'Qq':
save()
break
else:
print('error,please input correct instruction')
def add():
info = {}
name = input('Input name\n')
company = input('Input company\n')
state = input('Input State\n')
email = input('Input E-mail Address\n')
info['name'] = name
info['company'] = company
info['state'] = state
info['email'] = email
data.append(info)#添加一个人的信息到数据结构
def Display():
msg = input('which person would want to know(name)?\n')
exist = False #是否存在此人
for item in data:
if item['name'] == msg:
printdata(item)
exist = True
if not exist:
print('no such person!')
def Remove():
msg = input('which person would want to delete(by name)?\n')
exist = False #是否存在此人
for index,item in enumerate(data):
if item['name'] == msg:
printdata(item)
exist = True
while True:
info = input('is this person?(Y/N)\n')
if info in "Yy":
del(data[index])
print('Delete Success!')
break
elif info in 'Nn':
break
else:
print('please input correct inseruction')
if not exist:
print('no such person!')
def Show():
for item in data:
printdata(item)
def List():#自己实现其他的功能
pass
def other():
pass
def save():
fp = open(filename,'wb') #存好数据
pickle.dump(data,fp)
def load():
try:
fp = open(filename,'rb')
return pickle.load(fp)
except:
return []
def printdata(item):
print('name:' + item['name'] + '||' + 'company:' + item['company'] + '||'
+ 'state:' + item['state'] + '||' + 'email' + item['email'] + '\n')
if __name__ == '__main__':
main()