Python未解析参考

时间:2019-11-17 01:23:39

标签: python python-3.x scope

如果有人可以帮助我找到错误。变量名称(monthly_budgets)在函数外部以及调用时未解析。我是python的新程序员,所以帮助和任何提示将不胜感激。

def monthlbudgetoverview(monthly_expense_budget, monthly_savings_budget, monthly_spending_budget):
    monthly_expense_budget = float(budget_income_five * 4)
    monthly_savings_buget = float(budget_income_seven * 4)
    monthly_spending_budget = float(budget_income_eight * 4)
    return monthly_expense_budget, monthly_savings_budget, monthly_spending_budget

print("Your monthly bill budget is ${}" .format(monthly_expense_budget))
print("Your monthly savings budget is ${}" .format(monthly_savings_buget))
print("Your monthly spending budget is ${}" .format(monthly_spending_budget))

monthlbudgetoverview(monthly_expense_budget, monthly_spending_budget, monthly_spending_budget)

1 个答案:

答案 0 :(得分:0)

假设其他所有代码都可以在您的代码中正常工作,则这是正确的形式。

def monthlbudgetoverview(monthly_expense_budget, monthly_savings_budget, monthly_spending_budget):
    monthly_expense_budget = float(budget_income_five * 4)
    monthly_savings_buget = float(budget_income_seven * 4)
    monthly_spending_budget = float(budget_income_eight * 4)
    return monthly_expense_budget, monthly_savings_budget, monthly_spending_budget


monthly_expense_budget, monthly_savings_budget, \
monthly_spending_budget = monthlbudgetoverview(monthly_expense_budget, 
                                               monthly_spending_budget, monthly_spending_budget)

print("Your monthly bill budget is ${}".format(monthly_expense_budget))
print("Your monthly savings budget is ${}".format(monthly_savings_buget))
print("Your monthly spending budget is ${}".format(monthly_spending_budget))