Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32937 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2012-11-08 09:57 +0100 |
| Last post | 2012-11-08 09:57 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Unconverted data remains Peter Otten <__peter__@web.de> - 2012-11-08 09:57 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2012-11-08 09:57 +0100 |
| Subject | Re: Unconverted data remains |
| Message-ID | <mailman.3427.1352365037.27098.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web