当我将日期作为参数传递时,出现以下错误。请你的建议。我有两个变量“ srartdate”和“ enddate”已作为参数传递。
from datetime import date
class classOne:
def getDateComp(self, startDate, EndDate=None):
if EndDate is not None:
sdate = date(startDate)
edate = date(EndDate)
print(sdate +" -- "+edate)
else:
print('No Date')
def main():
objEQ = classOne()
objEQ.getDateComp(startDate='2020, 7, 6', EndDate='2020, 7, 9')
if __name__ == "__main__":
main()
**Error:**
sdate = date(startDate)
TypeError: an integer is required (got type str)
谢谢, 阿南德