我在项目A中有以下代码行
#filename : mod_dates
#Handles date calculations etc
import datetime
class datecalcs:
def __init__(self):
self.__menuChoice = 0
self.__datemonth = "not set"
self.__effectivedate = ""
self.__year = 0
self.__month = 0
return None
#
def interestcouponpaydates(self,effectivedate,couponday):
self.__effectivedate = effectivedate
year, month, day = map(int,self.__effectivedate.split('-'))
print(year)
print(month)
return self.__effectivedate
当我从另一个文件给他们打电话的时候
import mod_dates
import datetime
import modcalinputs
datesclass = mod_dates.datecalcs()
calcInputs = modcalinputs.calcinputs()
#Get the coupon date
interestdateeffective = calcInputs.interestdateffective()
interestdatecoupon = calcInputs.interestdatecoupon()
x = datesclass.interestcouponpaydates(interestdateeffective,interestdatecoupon)
print(x)
但是,这会在的x = datesclass...
行返回一个错误
year, month, day = map(int,self.__effectivedate.split('-'))
加薪:
> AttributeError: 'datetime.date' object has no attribute 'split'
当我用相同的语法从一个类似的项目运行到同一行时,它工作得很好。你知道我做错了什么吗?你知道吗
好像有什么东西在分配datetime.date日期对象到生效日期。不能调用split():
可以将其转换为字符串并拆分:
相关问题 更多 >
编程相关推荐