我不太熟悉Python,但我正在尝试创建一个程序,该程序可以接收文件名,工作表名称,每月付款,用户每月额外付款和本金贷款金额。然后,程序应使用提交的名称创建一个Excel文件,并使用提交的名称创建一个工作表。在Excel工作表中,开始从余额中减去每月付款,将其写入excel工作表并计算付款日期,然后对额外金额执行相同的操作并继续重复,直到余额达到0。我已经使用递归执行此操作,但我得到以下错误
zsh: segmentation fault python3 loanPayoff.py
以下是我的代码:
import datetime
import xlsxwriter
import sys
sys.setrecursionlimit(10**6)
# we create the workbook
def createWorkBook(workBookName, workSheetName, monthly, principal, additional, date):
#creating the workbook
workbook = xlsxwriter.Workbook(workBookName + '.xlsx')
worksheet = workbook.add_worksheet(workSheetName)
worksheet.write('A1', 'Date')
worksheet.write('B1', 'Mortgage principal amount')
worksheet.write('C1', 'Regular amount against principal')
worksheet.write('D1', 'Against principal additional')
payments(monthly, additional, principal, worksheet, 'regular', date, 1)
workbook.close()
# update the workbook's worksheet with the next date
def workBookUpdateDate(date, row, workSheet):
dateColumn = 0
workSheet.write(row, dateColumn, date)
# update the workbook's worksheet with the new balance
def workBookUpdateBalance(balance, row, workSheet):
balanceColumn = 1
workSheet.write(row, balanceColumn, balance)
# update the workbook's worksheet with the regular amount being paid
def workBookUpdateRegularAmount(regularAmount,row, workSheet):
regularAmountColumn = 2
workSheet.write(row, regularAmountColumn, regularAmount)
# update the workbook's worksheet with the additional amount being paid
def workBookUpdateAdditionalAmount(additionalAmount,row, workSheet):
additionalAmountColumn = 3
workSheet.write(row, additionalAmountColumn, additionalAmount)
# increment the date by two weeks
def addTwoWeeksToDate(date):
twoWeeks = datetime.timedelta(days=14)
newDate = date + twoWeeks
#print("DATE ......", format(newDate))
return newDate
繁星点点滴滴
当年话下
相关分类