Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32937
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Unconverted data remains |
| Date | 2012-11-08 09:57 +0100 |
| Organization | None |
| References | <CABgq=FxovqhZ4EgXkSm=LpwACM4L_svRKOZw=G06CV4bsmG-MA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3427.1352365037.27098.python-list@python.org> (permalink) |
Nikhil Verma wrote: > I have a list :- > L = ['Sunday November 11 2012 9:00pm ', 'Thursday November 15 2012 > 7:00pm ',\ [...] > 2012 7:00pm '] > final_event_time = [datetime.strptime(iterable, '%A %B %d %Y %I:%M%p') for > iterable in L] > > and having this error Unconverted data remains . I am trying to convert > all these in datetime object. Your date strings have trailing whitespace, try changing the format to final_event_time = [datetime.strptime(s, '%A %B %d %Y %I:%M%p ') for s in L] or apply strip to the date strings: final_event_time = [datetime.strptime(s.strip(), '%A %B %d %Y %I:%M%p') for s in L]
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Unconverted data remains Peter Otten <__peter__@web.de> - 2012-11-08 09:57 +0100
csiph-web