日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SHOPING 购物(学了老男孩视频写的)​

發布時間:2024/1/1 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SHOPING 购物(学了老男孩视频写的)​ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


#!/usr/bin/python
import syslog
import sys
this_year=2015



product=['apple','coffee','pc','rebot','clothes','licai'] ? ? ?#創建數組

price=[4999,30,8000,100000,1000,500] ? ? ? ? ? ? ? ? ? ??#創建數組

qingdan = [] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#創建數組

while True:
??????? try:

??????????????? gongz=int(raw_input('\033[33;1mplease input you gz:\033[0m').strip()) ? ??

??????????????? break ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

????????????????#輸入工資,不是數值異常處理

??????????????? #except ValueError:
??????? except ValueError:
??????????????? print "Error:you must input a? num"

while True:

??????? print '\033[35;1mplease looking for caidan\033[0m' ? ? ?? #輸出你的菜單

??????? for line in product: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

??????????????????? #在你的數組中循環

??????????????? print "\033[32;1m%s\t%s\033[0m" %(line,price[product.index(line)])

????????????????????#輸出你的購物清單

? ? ? ? ?? ?????if gongz < min(price): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? #判斷是否購買的起

? ? ? ? ? ? ? ? ?????print "\033[34;1m you didn't buy this is you buy\033[0m"

? ? ? ? ? ? ? ? ?????print "\033[34;1m",qingdan,"\033[0m" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

????????????????????#輸出你已經購買的

? ? ? ? ? ? ? ? ? ?? sys.exit()

? ? ? ? ? ? ? ?? else:

??????????????? goumai = raw_input('\033[32;1m you need shopping,please take it\033[0m') ? ?

????????????????????#選擇購買的物品

??????????????? if goumai=='exit': ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

????????????????????????? #exit 退出判斷

? ? ? ? ? ? ? ? ? ? ? ?print "\033[35;1m you buy ",qingdan,"\033[0m"

? ? ? ? ? ? ? ? ? ? ?? sys.exit()

??????????????? if goumai in product:

??????????????????????? if gongz < price[product.index(goumai)]: ? ? ? ? ? ? ? ? ??

????????????????????????????????#判斷是否購買的了

??????????????????????????????? print "\033[31;1myou can't buy",goumai,"youhave",gongz,"\033[0m" ?

????????????????????????????????#輸出不能買已經清單

??????????????????????????????? continue

??????????????????????? else:

??????????????????????????????? qingdan.append(goumai) ? ? ? ? ? ? ? ? ? ? ? ? ? ?

???????????????????????????????? #購買的物品添加到數組中

??????????????????????????????? gongz = gongz -? price[product.index(goumai)] ? ??

???????????????????????????????? #工資減去物品的價格

??????????????????????????????? print "\033[35;1m you buy ",qingdan,"you have ",gongz,"\033[0m"

??????????????? else:
??????????????????????? print "\033[31;1mdon't hava this wp,you have",gongz,"\033[0m"

??????????????????????? continue


轉載于:https://blog.51cto.com/bluechen/1695956

總結

以上是生活随笔為你收集整理的SHOPING 购物(学了老男孩视频写的)​的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。