python 代码问题

查看 49|回复 2
作者:Ancient7854   
网上看了一份python 代码
代码如下
import sysage_min = 22age_max = 60def getIncomeGrowth(i):    return max(0.03, 0.074 - (0.044 * i / 25))def getInterestRate(i):    return max(0.02, 0.0345 - (0.0145 * i / 10))def retire(age, s):    income_2021 = 75002    shebao_2021 = 27000    interest_2021 = 0.0345    if age  age_max:        print('你不在考虑退休的年纪')        return    for i in range(age, age_max + 1):        s = s - (income_2021+shebao_2021)        interest_rate = 1 + getInterestRate(i-age)        s = int(s * interest_rate)        print("{}岁,剩余{}".format(i,s))        if s  ".format(sys.argv[0]))    sys.exit(1)age = int(sys.argv[1])savings = int(sys.argv[2])retire(age, savings)
想要的结果类似是
35岁,剩余175657836岁,剩余171165837岁,剩余166518938岁,剩余161711639岁,剩余1567385
可是我python代码跑完之后结果是Usage: script.py  
是哪里出了问题

剩余, 代码

Ancient7854
OP
  

import sys
age_min = 22
age_max = 60
def getIncomeGrowth(i):
    return max(0.03, 0.074 - (0.044 * i / 25))
def getInterestRate(i):
    return max(0.02, 0.0345 - (0.0145 * i / 10))
def retire(age, s):
    income_2021 = 75002
    shebao_2021 = 27000
    interest_2021 = 0.0345
    if age  age_max:
        print('ä½ ä¸åœ¨è?ƒè™‘é??休的年纪')
        return
    for i in range(age, age_max + 1):
        s = s - (income_2021+shebao_2021)
        interest_rate = 1 + getInterestRate(i-age)
        s = int(s * interest_rate)
        print("{}岁,剩余{}".format(i,s))
        if s  ".format(sys.argv[0]))
    sys.exit(1)
age = int(sys.argv[1])
savings = int(sys.argv[2])
retire(age, savings)
olly2013   

这个python是需要输入参数的,你打开cmd,输入python game.py  35 1800000即可
您需要登录后才可以回帖 登录 | 立即注册

返回顶部