• 大小: 1KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Python
  • 标签: Python案例  

资源简介

此为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

评论

共有 条评论

相关资源