1
這將始終打印錯誤。我怎樣才能檢查日期是否在陣列中,並打印適當的東西?如何檢查日期是否在日期字符串列表中?
dates = [ "2012-09-03",
"2012-10-08",
"2012-10-09",
"2012-11-12",
# .. more values snipped for brevity
"2013-04-19",
"2013-05-27", ]
if date.today() in dates:
print "true"
elif date.today() not in dates:
print "false"
但是'dates.index(date.today())'不會更有用.. – 2012-08-28 01:44:50