-
Python3 安装
进入网址 https://www.python.org/downloads/windows/, 下载python3,根据系统下载64位或者32位。
-
下载完安装
安装教程
无脑双击勾选安装即可。 -
在桌面或者D:/盘,新建一个记事本,把以下内容复制进去,并重命名为 qty_unit_computer.py(注意后缀也要改,不要有txt)
import argparse
UNIT_MIN = 0.1
UNIT_MAX = 2.5
def get_decimal_places(number):
number_str = str(number)
decimal_index = number_str.find('.')
if decimal_index >= 0:
decimal_places = len(number_str) - decimal_index - 1
return decimal_places
return 0
if __name__ == "__main__":
cost = float(input('Input the Cost: '))
print('='*45)
print(" Quantity | Unit Price | Cost ")
print('='*45)
for quantity in range(int(int(cost)/UNIT_MAX), int(int(cost)/UNIT_MIN)):
unit = cost / quantity
if(get_decimal_places(unit) < 4):
print('{:^15}|{:^16}|{:^15}'.format(quantity, unit, cost))
print('-'*45)
print('=== Please double check the results !!! === ')
input('=== Press the enter key to exit. ===')
执行方法一(推荐)
4.直接双击 qty_unit_computer.py,弹出对话框,输入数字,回车得到结果,再次回车退出对话框。
执行方法二
- 在脚本保存的位置按 shift + 鼠标右键,找到“在此处打开Powershell窗口”,点击
5.然后输入以下命令回车,根据提示输入金额,再次回车即可。
python qty_unit_computer.py