Python实现购物车程序

作者: 日期:2019-08-13

#coding=utf-8
#Version:python 3.6.0
#Tools:Pycharm 2017.3.2
_date_ = '2018/4/16/016 14:50'
_author_ = 'Hongyong'
salary = int)
shoppingmart = []
凯发888国际娱乐网items = 
msg_items = '''
----------items----------
1. Huawei ¥ 2800
2. Earphone ¥ 300
3. Book ¥ 80
-------------------------
print
while True:
 shopindex = int)
 if salary items[shopindex-1][3]:
 shoppingmart.append
 salary -= int
 print)
 print
 decision = input
 print
 else:
 print
 recharge_ans = input
 if recharge_ans == "y":
 recharge = int)
 print
 salary += recharge
 print
 print
 decision = input
 print
 if decision == "q":
 break
 else:
 continue
print
print
print 

程序效果:

Please input your salary: 0
----------items----------
1. Huawei ¥ 2800
2. Earphone ¥ 300
3. Book ¥ 80
-------------------------
Please choose goods: 1
Your balance is not enough! Please try sth else.
Do you want to recharge y
Please input money: 30000
Please wait for a while...
You have recharged successfully!
And the balance is: 30000 now!
Do you want to quit now 
----------items----------
1. Huawei ¥ 2800
2. Earphone ¥ 300
3. Book ¥ 80
-------------------------
Please choose goods: 1
You have bought Huawei !
Your balance is: ¥ 27200
Do you want to quit now 
----------items----------
1. Huawei ¥ 2800
2. Earphone ¥ 300
3. Book ¥ 80
-------------------------
Please choose goods: 2
You have bought Earphone !
Your balance is: ¥ 26900
Do you want to quit now q
----------items----------
1. Huawei ¥ 2800
2. Earphone ¥ 300
3. Book ¥ 80
-------------------------
You have bought: [['1', 'Huawei', '¥', 2800], ['2', 'Earphone', '¥', 300]]
Your balance is: ¥ 26900
Welcome your next coming!

首页
电话
短信
联系