一只小白自学中

Python办公应用小程序(1)简易含税价格换算器.exe

工作上经常要互相换算产品几个不同税点的单价,虽然只是按个计算器的功夫,但是算的多了容易头晕。花一小时写了个小程序,顺便把pyinstaller装上了,试了一下打包exe的效果。


效果:



安装pyinstaller方法:

在cmd中输入并执行pip install pyinstaller


用pyinstaller打包exe方法:

1、在.py程序所在文件夹按shift+右键,在文件夹内打开cmd

2、输入并执行pyinstaller -F 文件名.py,等待打包过程结束

3、在dist文件夹中能找到打包好的exe程序



换算器源码:


def tax_exchange():

    while True:
                print("""
                ======1、不含税价格======
                ======2、含13%税价格=====
                ======3、含16%税价格=====
                ======4、含17%税价格=====
                """)

                usr_input = input("请选择输入的价格类型,输入Q退出\n")

        if usr_input == "1":
                        price = input("请输入不含税价格:")
                        tax_free = float(price)
                        tax_13 =  tax_free * 1.13
            tax_16 = tax_free * 1.16
            tax_17 = tax_free * 1.17
            print("不含税价格为:", price)
                        print("含13%税价格为:", round(tax_13, 2))
                        print("含16%税价格为:", round(tax_16, 2))
                        print("含17%税价格为:", round(tax_17, 2))

        elif usr_input == "2":
                        price = input("请输入含13%税价格:")
                        tax_free = float(price)/1.13
            tax_16 = tax_free * 1.16
            tax_17 = tax_free * 1.17
            print("含13%税价格为", price)
                        print("不含税价格为:", round(tax_free, 2))
                        print("含16%税价格为:", round(tax_16, 2))
                        print("含17%税价格为:", round(tax_17, 2))

        elif usr_input == "3":
            price = input("请输入含16%税价格:")
                        tax_free = float(price) / 1.16
            tax_13 = tax_free * 1.13
            tax_17 = tax_free * 1.17
            print("含16%税价格为", price)
                        print("不含税价格为:", round(tax_free, 2))
                        print("含13%税价格为:", round(tax_13, 2))
                        print("含17%税价格为:", round(tax_17, 2))

        elif usr_input == "4":
                        price = input("请输入含17%税价格:")
                        tax_free = float(price) / 1.17
            tax_13 = tax_free * 1.13
            tax_16 = tax_free * 1.16
            print("含17%税价格为", price)
                        print("不含税价格为:", round(tax_free, 2))
                        print("含13%税价格为:", round(tax_13, 2))
                        print("含16%税价格为:", round(tax_16, 2))

        elif usr_input == "q" or "Q":
                        exit()


tax_exchange()

评论

© Melody | Powered by LOFTER