Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从列表中找到最大时间值:
num[2] = 2012-12-16 16:56:31
我尝试过以下操作:
max =0 for num in list: if num[2] > max: max = num print max
但它显示错误:
if num[5] > max: TypeError: can't compare datetime.datetime to int
你可以做
max(my_dates)
不要调用您的列表,列表,因为这会影响内置并在以后产生令人困惑的错误。
不要在此链接中为您的变量命名