資源簡介
此為Python的點餐小Demo,便于Python入門學習,Python環境搭建可參考博客:http://blog.csdn.net/qq_36275193/article/details/78225236 Python爬蟲按鈕參考:http://blog.csdn.net/qq_36275193/article/details/78224837

代碼片段和文件信息
money=0
def?caidan():
????print(“編號??????菜??????名??????價格?“)
????print(“1??????????肉末茄子????????17??“)
????print(“2??????????香菇青菜????????9???“)
????print(“3??????????酸辣大白菜??????8???“)
????print(“4??????????川香回鍋肉??????23??“)
????print(“5??????????番茄蛋湯????????8???“)
????print(“6??????????茼蒿????????????12??“)
????seletecd()
def?istrue(num):
????try:
????????int(num)?
????????return?True
????except?ValueError:
????????return?False
????
def?duxie(scontext):
????global?money
????f2=open(‘D:\\App\\aaaaa.txt‘‘w‘)
????f2.write(context)
????f3=open(‘D:\\App\\money.txt‘‘r‘)
????if?s==‘1‘:
????????f2.write(“肉末茄子*(1)??17元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):
????????????money2=17+int(money1)
????????else:
????????????money2=17
????elif?s==‘2‘:
????????f2.write(“香菇青菜*(1)??9元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):
????????????money2=9+int(money1)
????????else:
????????????money2=9???????
????elif?s==‘3‘:
????????f2.write(“酸辣大白菜*(1)??8元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):
????????????money2=8+int(money1)
????????else:
????????????money2=8??
????elif?s==‘4‘:
????????f2.write(“川香回鍋肉*(1)??23元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):????????????
????????????money2=23+int(money1)
????????else:
????????????money2=23???
????elif?s==‘5‘:
????????f2.write(“番茄蛋湯*(1)??8元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):
????????????money2=8+int(money1)
????????else:
????????????money2=8??????
????elif?s==‘6‘:
????????f2.write(“茼蒿*(1)??12元“+“\n“)
????????money1=f3.read()
????????if?istrue(money1):
????????????money2=12+int(money1)
????????else:
????????????money2=12??????
????????
????f3=open(‘D:\\App\\money.txt‘‘w‘)
????f2=open(‘D:\\App\\aaaaa.txt‘‘w‘)
????f2.write(context)
????f3.write(str(money2))
????f2.close()
????f3.close()
????
def?seletecd():
????f=open(“D:\\App\\aaaaa.txt““r“)
????s1=f.read()
????f.close()
????print(“?????????????????????“)
????print(“已點菜品:“+“\n“+s1)
????f3=open(‘D:\\App\\money.txt‘‘r‘)
????moneynum=f3.read()
????f3.close()
????print(“小計:“+moneynum)
????print(“????????????????????????“)
????selete=input(“請選擇您喜愛的菜品“)
????duxie(seletes1)
????one=input(“確認訂單請按Y,退出請按N,按任意鍵繼續點單“)
????if?one==‘y‘:
????????f=open(“D:\\App\\aaaaa.txt““r“)
????????s1=f.read()
????????f.close()
????????print(“?????????????????????“)
????????print(“所有菜品:“+“\n“+s1)
????????f3=open(‘D:\\App\\money.txt‘‘r‘)
????????moneynum=f3.read()
????????f3.close()
????????print(“小計:“+moneynum)
????????if?istrue(moneynum):
????????????if?int(moneynum)>=25?and?int(moneynum)<45:
????????????????print(“您可參加滿25減10元活動“)
????????????????suremoeny=int(moneynum)-10
????????????????print(“此次訂單需支付:“+str(suremoeny))
????????????????f3=open(‘D:\\App\\money.txt‘‘w‘)
????????????????f3.write(““)
????????????????f2=open(‘D:\\App\\aaaaa.txt‘‘w‘)
????????????????f2.write(““)
????????????????f2.
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????????0??2017-09-19?16:19??新建文件夾\aaaaa.txt
?????文件????????4696??2017-05-15?17:13??新建文件夾\diancan.py
?????文件???????????0??2017-09-19?16:19??新建文件夾\money.txt
- 上一篇:apriori python 3
- 下一篇:python300G視頻書籍教程.zip
評論
共有 條評論