如何访问datetime的属性
程序代码:
from datetime import datetime import sys def get_month_range(date): # print(date.year()) //报错:TypeError: 'int' object is not callable print(date.month()) print(date.day()) FirstDay = datetime(date.year(),date.month(),1) NextDay = datetime(date.year(),date.month()+1,1) return ( FirstDay.timestamp(),NextDay.timestamp() ) while True: line = sys.stdin.readline() line = line.strip() if line == '': break date = datetime.strptime(line, "%Y-%m-%d") print(get_month_range(dete))
初学Python,get_month_range(date)函数体里,调用datetime对象的year属性应该怎么写才是??