计算抵押贷款python 3.8.3

2024-04-27 10:21:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图计算抵押/贷款,发现堆栈溢出代码(2018年12月14日17.13 Kravietz),但它不起作用

代码:

import mortgage
m = mortgage.Mortgage(interest=0.0375, amount=350000, months=360)
mortgage.print_summary(m)

首先,我安装了模块mortgage。第一个错误:

AttributeError-module mortgage has no attribute Mortgage

事实上,对于dir(mortgage),我发现没有属性Mortgage。 我将Mortgage更改为loan,但没有结果。 我试了一下,没有结果。 我试图在第三行print(mortgage.pr ...)上添加打印,没有结果

错误:

NameError - name "interest" is not defined
TypeError - "module" is not callable
NameError - name "mortgage" is not defined

Tags: 代码nameis堆栈错误notmoduleprint
2条回答

您需要使用Kravietz在his answer中引用的抵押模块,它可以在以下位置找到:https://github.com/jbmohler/mortgage

这可以通过创建一个函数来轻松实现,该函数将计算所有输入,如利息、金额、月份,并返回计算结果 等等无需导入任何模块!我建议找一些简单的函数来计算数字,然后根据您的需要进行编辑!:)

相关问题 更多 >