- 创建一个列表存储书籍信息,包括书名,作者名,价格
- 创建一个用户列表,存储用户名和密码
- 制作一个登录和注册界面,登录后可以添加书籍,删除书籍,修改书籍和查找书籍
- 制作其他合理功能
print('''
----------图书管理系统-----------
----------1-注册-----------------
----------2-登录-----------------
----------3-退出-----------------
''')
infos=[['a','b','c']]
users=[['1','2'],['2','3']]
b=1
c=1
while b:
a=1
chose=int(input("please input your chose:"))
if chose==1:
while c:
name=input("please input your name:")
for i in users:
if i[0]==name:
print("用户已存在,请重新输入")
break
else:
user=[]
passwd=input('please input your password:')
user.append(name)
user.append(passwd)
users.append(user)
print("注册成功")
c=0
elif chose==2:
name=input("please input your name:")
passwd=input('please input your password:')
for i in users:
if name==i[0] and passwd==i[1]:
print("congrulations")
while a:
print('''
1-添加
2-删除
3-修改
4-查找
5-返回上一级''')
c1=int(input("please input your chose:"))
if c1==1:
info=[]
title=input("the tile of book:")
author=input("the author of name:")
price=input("the price of book:")
info.append(title)
info.append(author)
info.append(price)
infos.append(info)
print("添加成功")
elif c1==2:
print('''
请选择按什么删除
1-书名
2-作者名
3-全部删除''')
c2=int(input("please input your chose:"))
if c2==1:
t1=input("delete book's name:")
for j in infos:
if j[0]==t1:
infos.remove(j)
print("删除成功")
break
else:
print("not this book")
elif c2==2:
a1=input("the author of name:")
for j in infos:
if j[1]==a1:
infos.remove(j)
print("删除成功")
break
else:
print("not the author")
elif c2==3:
infos.clear()
print("删除成功")
else:
print("your chose is error")
elif c1==3:
print('''
请选择按什么修改
1-书名
2-作者名''')
c2=int(input("please input your chose:"))
if c2==1:
t1=input("revise's book:")
for j in infos:
if t1==j[0]:
title=input("the tile of book:")
author=input("the author of name:")
price=input("the price of book:")
j[0]=title
j[1]=author
j[2]=price
print("修改成功")
break
else:
print("not this book")
elif c2==2:
a1=input("the author of name:")
for j in infos:
if a1==j[1]:
title=input("the tile of book:")
author=input("the author of name:")
price=input("the price of book:")
j[0]=title
j[1]=author
j[2]=price
print("修改成功")
break
else:
print("not the author")
else:
print("your chose is error")
elif c1==4:
q=0
print('''
请选择按什么查找
1-书名
2-作者名
3-全部显示''')
c2=int(input("please input your chose:"))
if c2==1:
t1=input("search's book:")
for j in infos:
if t1==j[0]:
print("title:"+j[0]+" author:"+j[1]+" price:"+j[2])
q+=1
if q==0:
print("not this book")
elif c2==2:
a1=input("the author of name:")
for j in infos:
if a1==j[1]:
print("title:"+j[0]+" author:"+j[1]+" price:"+j[2])
q+=1
if q==0:
print("not this book")
elif c2==3:
for j in infos:
print("title:"+j[0]+" author:"+j[1]+" price:"+j[2])
else:
print("your chose is error")
elif c1==5:
a=0
print('''
----------图书管理系统-----------
----------1-注册-----------------
----------2-登录-----------------
----------3-退出-----------------
''')
else:
print("your chose is error")
break
else:
print('not the user')
elif chose==3:
b=0
else:
print("your chose is error")