TypeError: 'int' object is not callable with max(datetime) list

时间:2018-09-28 17:47:13

标签: python-3.x datetime max datetime-format

I should be able to use max() with a datetimes list:

import sys, os, datetime

pre_dates = [row[0] for row in arcpy.da.SearchCursor(prelim, "PRE_DATE")]
....
>>>pre_dates = [[datetime.datetime(2017, 9, 15, 0, 0),
datetime.datetime(2017, 9, 15, 0, 0),datetime.datetime(2017, 10, 25, 0, 0),
datetime.datetime(2018, 19, 11, 0, 0),datetime.datetime(2017, 7, 6, 0, 0),
datetime.datetime(2017, 4, 15, 0, 0)]

date = max(pre_dates)

This seemed to work previously and several other answers to similar questions seemed to confirm this. Now it is throwing this error:

TypeError: 'int' object is not callable

What's the problem here? I need to get the max (or most current) date from this list of datetime dates and converting it using strftime('%m/%d/%y') must be done afterwards. Any suggestions as to how to resolve this?

0 个答案:

没有答案