45 int_ID = int(choose_ID) # 输入商品序号转化为int类型,若不报错,向下执行 46 if int_ID in [i['id'] for i in goods]: # 判断商品序号是否存在 47 product_quantity = int(input("\033[1;36mWhat`s the quantity of products you want to buy:\033[
Function:Shopping cart system simulation 1、模拟用户3次验证登录 2、通过分页的方式显示商品信息 3、用户进行购物(加入到购物车) 4、用户进行结账 5、将用户的购物记录、登录次数、账户余额等同步到最新的文件中 6、用户通过模糊匹配查询的方式查询相应的购物记录 """ #读取个人账户的相关信息 fr1 = open("perso...
salary-= p_item[1]print("Added %s into shopping cart,your c b is \033[31;1m%s\033[0m"%(p_item, salary))else:print("\033[41;1m 余·额不足,%s \033[0m"%salary)else:print("product code [%s] is not exist"%user_choice)elifuser_choice =='q':print("---shopping list---")...
print("Added %s into shopping cart,your current balance is\033[31;1m%s\033[0m"%(p_item,salary))# \033[31;1m%s\033[0m输出结果加颜色 else: print("\033[41;1m你的余额只剩[%s],不可以购买商品\033[0m"%salary) else: print("product code [%s] is not exist!"%user_choic) elifuser_...
[1] <= salary:#商品价格小于用户余额,即能买得起26shopping_list.append(p_item)27salary = salary - p_item[1]28print("Added %s into shopping cart,Your current balance is %s"%(p_item,salary))29else:30print("余额不足")31else:32print("product code [%s] is not exist!"%(user_choice)...
name 定位:find_element_by_name()HTML 规定,利用 name 来指定元素的名称,因此也可以利用这个属性来寻找元素 browser.find_element_by_name(“shopping_cart”) class 定位:find_element_by_class_name()HTML 规定,class 用于指定元素的类别名称,其用法与 id、name 类似。 browser.find_element_by_class_name(“...
# 重构前classShoppingCart:def__init__(self,items):self.items=itemsself.tax_rate=get_tax_rate()defcalculate_total(self):grand_total=0foriteminself.items:grand_total+=self.calculate_item_total(item)returngrand_total*(1+self.tax_rate)defcalculate_item_total(self,item):# 包含商品价格计算、折...
classTestPotter(unittest.TestCase):shopping_cart=NonedefsetUp(self):self.shopping_cart=ShoppingCart()deftest_buy_one_book(self):self.shopping_cart.add_book(id=1)value=self.shopping_cart.buy()self.assertEqual(value,8,'Should be 8 and it gives %f'%value)deftest_buy_two_books_different(self...
An e-commerce project, whose functions include user center, receiving address, e-commerce management background, permission management, commodity management, commodity SKU, shopping cart module, order module, payment module (Alipay, WeChat payment), comm
print("Added %s into shopping cart, your current balance is \033[31;1m%s\033[0m" %(p_item, salary)) else : print("money lesser") else: print("produce code [%s] is not exist!" %user_choice) elif user_choice == 'q' :