#__author__:"Jay guo"
#__date__:2016/9/8
login_flag = False
def login(flag):
def func(f):
def inner():
global login_flag
if login_flag == False:
nameuser = input("input your name:> ")
print (nameuser)
passwd = input ("input your password: > ")
print (passwd)
if flag == "jingdong":
# 打开文件
with open("jingdong","r") as file:
for i in file:
i = eval(i)
if nameuser ==list(i.keys())[0] and passwd == i[list(i.keys())[0]]:
print ("welcome jingdong")
login_flag = True
elif flag == "weixin":
with open("weixin", "r") as file:
for i in file:
i = eval(i)
if nameuser == list(i.keys())[0] and passwd == i[list(i.keys())[0]]:
print("welcome weixin")
login_flag = True
f()
return inner
return func
@login("jingdong")
def home():
print ("input home")
@login("weixin")
def finance():
print ("input finance")
@login("jingdong")
def book():
print ("input book")
def home_goods(flag):#商品
goods_list= []
shop_list = ("car", "competer", "water")
finance_list = ("stock","loan","buy")
book_list = ("十万个为什么","西游记","三国演义")
list1 = [shop_list,finance_list,book_list]
while True:
for i,j in enumerate(list1[flag-1],1):
print(i,":",j)
choice = input("input goods number(q : quit) :> ")
if choice == "q":
break
print (list1[flag-1][int(choice)-1])
goods_list.append(list1[flag-1][int(choice)-1])
return goods_list
list_paper = ("home","finance","book")
home_shop = []
finance_shop = []
book_shop = []
while True:
for i,j in enumerate(list_paper,1):
print (i,":",j)
shop = input("choice paper:>")
if shop == "q":
for i in home_shop:
print(i)
for i in finance_shop:
print(i)
for i in book_shop:
print(i)
break
elif int(shop) == 1:
home()
home_shop = home_goods(1)
elif int(shop) == 2:
finance()
finance_shop = home_goods(2)
elif int(shop) == 3:
book()
book_shop =home_goods(3)