get the min date from a list

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Aug 10 06:42:53 EDT 2014


On 10/08/2014 08:14, luofeiyu wrote:
>  >>> date
> ['Sat, 09 Aug 2014 07:36:46 -0700', 'Fri, 8 Aug 2014 22:25:40 -0400',
> 'Sat, 9 Au
> g 2014 12:46:43 +1000', 'Sat, 9 Aug 2014 12:50:52 +1000', 'Sat, 9 Aug
> 2014 02:51
> :01 +0000 (UTC)', 'Sat, 9 Aug 2014 13:03:24 +1000', 'Sat, 09 Aug 2014
> 13:06:28 +
> 1000', 'Fri, 8 Aug 2014 20:48:44 -0700 (PDT)', 'Fri, 8 Aug 2014 23:52:09
> -0700 (
> PDT)', 'Sat, 09 Aug 2014 09:15:50 +0200', 'Sat, 9 Aug 2014 01:49:54
> -0600', 'Sat
> , 9 Aug 2014 01:57:18 -0600', 'Sat, 9 Aug 2014 17:54:23 +0800 (CST)',
> 'Sat, 9 Au
> g 2014 12:49:08 +0200', 'Sat, 9 Aug 2014 07:31:09 -0400', 'Sat, 9 Aug
> 2014 07:34
> :16 -0400', 'Sat, 09 Aug 2014 11:39:16 +0000', 'Sat, 9 Aug 2014 07:40:41
> -0400',
>   'Sat, 9 Aug 2014 11:46:54 +0000', 'Sat, 09 Aug 2014 13:48:17 +0200',
> 'Sat, 09 A
> ug 2014 21:53:11 +1000', 'Sat, 09 Aug 2014 14:13:13 +0200', 'Sat, 09 Aug
> 2014 08
> :16:08 -0400', 'Sat, 09 Aug 2014 22:17:25 +1000', 'Sat, 09 Aug 2014
> 14:33:54 +02
> 00', 'Sat, 9 Aug 2014 14:46:01 +0200', 'Sat, 09 Aug 2014 10:34:58
> -0300', 'Sat,
> 09 Aug 2014 11:34:22 -0400', 'Sat, 09 Aug 2014 12:16:56 -0400', 'Sat, 09
> Aug 201
> 4 12:26:38 -0400', 'Sat, 09 Aug 2014 13:29:59 -0400', 'Sat, 09 Aug 2014
> 13:43:33
>   -0400', 'Sat, 9 Aug 2014 11:30:35 -0300', 'Sat, 09 Aug 2014 20:14:20
> +0200', 'S
> un, 10 Aug 2014 08:18:34 +1000', 'Sat, 9 Aug 2014 18:23:08 -0400 (EDT)',
> 'Sat, 0
> 9 Aug 2014 18:30:17 -0400', 'Sat, 09 Aug 2014 18:31:38 -0400', 'Sun, 10
> Aug 2014
>   09:43:44 +1000', 'Sat, 9 Aug 2014 18:27:15 -0700 (PDT)', 'Sun, 10 Aug
> 2014 03:4
> 4:56 +0200', 'Sun, 10 Aug 2014 01:55:24 +0000 (UTC)', 'Sun, 10 Aug 2014
> 02:01:06
>   +0000 (UTC)', 'Sat, 9 Aug 2014 19:41:08 -0700 (PDT)', 'Sat, 9 Aug 2014
> 22:51:29
>   -0400 (EDT)', 'Sun, 10 Aug 2014 07:34:44 +0200', 'Tue, 5 Aug 2014
> 01:55:24 +000
> 0 (UTC)']
>  >>> min(date)
> 'Fri, 8 Aug 2014 20:48:44 -0700 (PDT)'
>
> The result is wrong,the min date should be 'Tue, 5 Aug 2014 01:55:24 +000
> 0 (UTC)' ,how can i get it ?

The result is probably correct (I haven't checked) as you're comparing 
strings.  I'll leave you to read the docs to find out how to convert the 
strings to datetimes and compare them.  Start here 
https://docs.python.org/3/ as that way you'll get used to finding your 
way around them.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list