menu = {
'1': dict(name='草莓冰淇淋', price=20),
'2': dict(name='香草冰淇淋', price=10),
'3': dict(name='香蕉冰淇淋', price=15),
'5': dict(name='巧克力冰淇淋', price=30),
}
def showmenu(menu):
for k, item in sorted(menu.items()):
轿拆 print "%(key)s: %(name)s 价格%(price).2f" % dict(key=k, **item)
def menuchoice(menu):
while True:
孝大showmenu(menu)
c = raw_input("Your Choice('.' for end): ")
if c == '.':
break
else:
闭慎枣yield menu.get(c)
customerchoice = filter(None, menuchoice(menu))
print "Total: %.2f" % sum(map(lambda x: x["price"], customerchoice))
User={}List=open("USER.txt","r")
for _list in List:
_List=_list.split()
User[_List[0]]=_list[2]
List.close()
List1=open("USER.txt","a")
print ("Welcome")
print ("是否需要注册?(Y/N):")
a1=True
while a1:
_a=input("请输入选择:")
if _a not in ["Y","y","N","n"]:
print ("WARRING:请输入Y或者N进行选择")
continue
else:
a1=False
a1=True
if _a in ["Y","y"]:
print ("----------------注册界面----------------")
while a1:
a_id=input("请输入ID:")
if a_id in User:
print ("ID被占用,请重新输入!")
continue
else:
while a1:
a_pass=input("请输入密码:")
a_pass1=input("请再次输入密码:")
if a_pass!=a_pass1:
print ("两次密码不正确!重新输入")
continue
else:
List1.write(a_id)
List1.write("\t")
List1.write(a_pass)
List1.write("\n")
print ("注册完毕,将转入登录界面!")
a1=False
else:
None
List1.close()
print ("----------------登录界面----------------")
a1=True
while a1:
b1=input("请输入账号:")
b2=input("请输入密码:")
try:
User[b1]
except:
print ("账号错误,请重新输入!")
continue
if User[b1]!=b2:
print ("账号密码输入错误,请重新输入!")
continue
else:
a1=False
print ("----------------点餐界面----------------")
print ("1:茄子 10元\n2:白菜:15元\n3:萝卜:20元\n4:肉:30元")
Dict={"1":"茄子","2":"白菜","3":"萝卜"仿悔郑,"4":"肉"}
Price={"1":10,"2":15,"3":20,"4":30}
print ("请输入要点的菜编号(没输入一份前改菜请按一次回车):")
a1=True
_a1=1
az=[]
while a1:
ax=input("第%s份(点Q退出点餐):" %(_a1))
if ax=="q" or ax=="Q":
print ("结束点餐!!备颂!")
a1=False
elif ax not in ["1","2","3","4"]:
print ("未开发餐内容!,请重新输入")
continue
else:
az.append(ax)
_a1+=1
a1=True
total=0
while a1:
if az==[]:
print ("您没有点餐!!!!,退出点餐系统!!!")
a1=False
else:
print ("您的餐列表:")
for zz in az:
print ("%s\t%s" %(Dict[zz],Price[zz]))
total+=Price[zz]
print ("一共%s元" %(total))
a1=False
print ("欢迎下次光临!!")
需要Python3以上 不然自己去改print
在PYTHON所在文件夹里做一个USER.txt 用来存储账号密码用
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)