import pymysql
db = pymysql.connect(host="192.168.146.209", user="root",password="123", db="pikachu", port=3306)
cur = db.cursor()
sql = "select * from pokemon3"
cur.execute(sql)
results = cur.fetchall()
total_money = 0
while True:
print(results)
goods = input('please select your goods(stop:0) : ')
if goods == '1':
num = int(input('how many chips do you want : '))
total_money = total_money+num*10
print(total_money)
elif goods == '2':
num = int(input('how many white_wine do you want : '))
total_money = total_money+num*20
print(total_money)
elif goods == '3':
num = int(input('how many sugars do you want : '))
total_money = total_money+num*5
print(total_money)
elif goods == '0':
break
while True:
print(' ')
print('you have custom %s'%(total_money))
money = int(input('please enter your money : '))
if money >= total_money:
print('still money:%s'%(money-total_money))
break
else:
print('your money is not enough')
python编程-购物车
最新推荐文章于 2023-05-20 16:59:43 发布