shopping = [] file = (=)
user_data1 = ((file.readline()))
file3 = (=)
wage_data = ((file3.readline()))
user = ()
passwd1 = ()
user user_data1 passwd1 user_data1[user]:
()
choice = ()
choice == :
shopping_history1 = (=)
shopping_wage1 = (=)
list1 = ((shopping_history1.readline()))
list2 = ((shopping_wage1.readline()))
shopping_history1.close()
shopping_wage1.close()
(% list1[user]% list2[user])
user user_data1 passwd1 user_data1[user]:
()
:
wage = ()
item = [(userpasswd1)]
dict1 = (item)
dict1.update(user_data1)
file1 = (=)
file1.write((dict1))
file2 = (=)
wage1 = [(userwage)]
dict2 = (wage1)
dict2.update(wage_data)
file2.write((dict2))
file1.flush()
file2.flush()
file1.close()
file2.close()
product_list = [
()()()()()]
file4 = (=)
wage_data2 = ((file4.readline()))
wage = (wage_data2[user]):
indexitem (product_list): (indexitem)
choice = ()
(choice) < (product_list): choice_item = product_list[(choice)] choice_item[] <= wage: shopping_history1 = (=)
list1 = ((shopping_history1.readline()))
shopping.append(choice_item[])
list1[user] = shopping[:]
wage -= choice_item[] (% (choice_item[]wage))
()
(% (usershopping[:]))
shopping_history2 = (=)
shopping_history2.write((list1))
wage_history = (=)
list3 = ((wage_history.readline()))
list3[user] = wage
wage_history1 = (=)
wage_history1.write((list3))
wage_history1.flush()
wage_history1.close()
wage_history.close()
shopping_history2.flush()
shopping_history2.close()
shopping_history1.close()
(list1)
:
(% wage)
(choice) == :
()
file4.close()
购物车实现
原文:http://blog.51cto.com/3888723/2063595