购物车小程序

Posted shenyueboy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了购物车小程序相关的知识,希望对你有一定的参考价值。

salary = input("your salary =")
_salary = int(salary)
list = []
for i in range(10):
a = "1、iphone6s need 5800"
b = "2、mac book need 9000"
c = "3、coffee need 32"
d = "4、python book need 80"
f = "5、bicycle need 1500"
print(a)
print(b)
print(c)
print(d)
print(f)
_a = 5800
_b = 9000
_c = 32
_d = 80
_f = 1500
choose = input("The number you choose is:")
if choose.isdigit():
_choose =int(choose)
if _choose == 1:
if _salary - _a>0:
print("已加入 iphone6s 到你的购物车,当前余额:", _salary - _a)
_salary = _salary - _a
list.append("iphone6s 5800")
else:
print("余额不足:",(_salary - _a))
break
elif _choose == 2:
if _salary - _b>0:
print("已加入 mac book 到你的购物车,当前余额:", _salary - _b)
_salary = _salary - _b
list.append("mac book 9000")
else:
print("余额不足:",(_salary - _b))
break
elif _choose == 3:
if _salary - _c>0:
print("已加入 coffee 到你的购物车,当前余额:", _salary - _c)
_salary = _salary - _c
list.append("coffee 32")
else:
print("余额不足:",(_salary - _c))
break
elif _choose == 4:
if _salary - _d>0:
print("已加入 python book 到你的购物车,当前余额:", _salary - _d)
_salary = _salary - _d

list.append("python book 80")
else:
print("余额不足:",(_salary - _d))
break

elif _choose == 5:
if _salary - _f>0:
print("已加入 bicycle 到你的购物车,当前余额:", _salary - _f)
_salary = _salary - _f
list.append("bicycle 1500")
else:
print("余额不足:",(_salary - _f))
break
else:
if choose == ‘quit‘:
break
print("你已购买以下商品:")
print()
print(list)
print()
print("你的余额为:",_salary)
print()
print("欢迎下次光临")









































































以上是关于购物车小程序的主要内容,如果未能解决你的问题,请参考以下文章

泡泡玛特小程序怎么加购物车买三个

微信小程序转载:微信小程序之购物车功能

微信小程序 将商品添加到购物车 数据怎么存

popmart小程序怎样加购物车

cnsc中服免税店小程序 如何加入购物车

Python小程序之购物车