我有一个python文件,function_bucket.py,从该文件我需要import将该modalprem()函数转换为另一个Array1.py文件。下面我提到了这两个函数的代码,但是在调用函数“ No module named modalprem()”时,请帮助解决~
代码为 function_bucket.py
def main():
def modalprem():
return 1
if __name__ == "__main__":
main()
代码为 Array1.py
import numpy as np
from Function_Bucket import modalprem()
modalprem()
def main():
EA=50
PT = 15
PPT = 5
AP = 50000
Mode = 12
PM = np.arange(12*PT+1)
PY = np.arange(12*PT+1)
AGE = np.arange(12*PT+1)
PREM = np.arange(12*PT+1)
i=1
Modal_Premium = modalprem()
print(Modal_Premium)
if (Mode == 1):
Modal_Premium = AP
elif (Mode==2):
Modal_Premium = AP *0.5131
elif (Mode==4):
Modal_Premium = AP *0.2605
elif (Mode==12):
Modal_Premium = AP *0.0886
while(i <180):
PM[i] = i
PY[i] = int( (i+11)/12)
AGE[i] = EA + PY[i] -1
if (PM[i]<=PPT*12 and ((PM[i]-1)%(12/Mode) == 0)):
PREM[i] = Modal_Premium
else:
PREM[i] = 0
i = i+1
print(PM)
print(PY)
print(AGE)
print(PREM)
if __name__ == "__main__":
main()
在Array1.py中可以试下
from . import function_bucket
function_bucket.modalprem()
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。