import time
import pickle
import sys
import os
#定义账单和购物车
Bill = {}
products = {}
shoplist = []
#define Bill function, used to record billing details(account/time/describe/money).
def Bill(Account,Time,Description,RMB):
Bill= {"Account":Account,"Time":Time,"Description":Description,"RMB":RMB}
#用pickle模块把账单信息存到bill文件中去
pickle.dump(Bill,open("bill","ab"))
#-----------------------------------------------------------------------------------------------------
#购物功能
def shop():
print( '\033[;32mWelcome to shopping!\n\033[0m')
with open('shops') as f:
for line in f.readlines():
print('{}'.format(line.strip()))
while 1:
with open('shops') as f:
for line in f.readlines():
line = line.strip()
commodity = line.split()[0]
price = line.split()[1]
products[commodity] = price
choice = input("\033[;32mPlease input you want to buy>>\033[0m").strip()
if len(choice) == 0:
continue
elif choice == 'back':
list()
if choice in products:
remaining = pickle.load(open('userinfo','rb'))
if int(products[choice])>int(remaining[accountAuth][2]):
print("In your card remaining sum already insufficiency, please prompt sufficient value!'")
else:
while 1:
shoplist.append(choice)
new_remaining = int(int(remaining[accountAuth][2]