Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86020
| Date | 2015-02-21 17:47 +1100 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: subprocess command fails |
| References | <9edb2725-c91b-4ae2-b5f4-91a80ed3afe8@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18950.1424501263.18130.python-list@python.org> (permalink) |
On 20Feb2015 21:14, Brad s <bcddd214@gmail.com> wrote:
>Time adjustment error:
>
># python3.4 timefix.py
>2015022105
>2015-02-21 05:00:00
>Traceback (most recent call last):
> File "timefix.py", line 15, in <module>
> ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H')
>TypeError: must be str, not datetime.datetime
>
>
>
># cat timefix.py
>#!/usr/bin/python3.4
>import subprocess
>import sys
>from datetime import datetime
>import datetime
>from time import gmtime, strftime
>
>pretime = strftime("%Y%m%d%H", gmtime())
>time = datetime.datetime.strptime(pretime,'%Y%m%d%H')
>print(pretime)
>print (time)
>plustime = datetime.timedelta(days=730)
>timeadd = (time + plustime)
>str(timeadd)
>ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H')
>#timeadd = timeadd.replace(tzinfo=UTC())
>print (timeadd)
>print (ndate)
Well, timeadd is a date object, yes? strptime is for parsing a string for date
information, but timeadd is already parsed, as it were. Why are you calling
strptime at all?
Cheers,
Cameron Simpson <cs@zip.com.au>
stomping on roses and strangling kittens
leaving no fingerprints cause we wear mittens
inflatable prostitutes tied up with strings
these are a few of my favorite things
- gypsy <gypsy@popeet!c3.com>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 15:30 -0800
Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 12:11 +1100
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 20:47 -0800
Re: subprocess command fails Larry Hudson <orgnut@yahoo.com> - 2015-02-21 12:33 -0800
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 21:14 -0800
Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 17:47 +1100
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 22:41 -0800
csiph-web