Python 2.7 strftime TypeError
up vote
0
down vote
favorite
I'm using python 2.7.x:
import datetime
...
def _log(error_level, message):
try:
d = datetime.datetime.now()
date_template = d.strftime("%Y.%m.%d - %H:%M:%S")
...
except:
sv_custom_utils.simple_exception_info()
In 99% it is running without any problems, but sometimes I get an error:
ERROR:root:
2018.11.21 - 15:58:25:
Top: file: [sv_logger.py], method: _log()
Root: file: [sv_logger.py], line 51, cause: in _log [date_template = d.strftime("%Y.%m.%d - %H:%M:%S")]
TypeError: a float is required
What could be a reason? Python is running on Ubuntu 16/18. Does that mean that d should be a float?
python-2.7
add a comment |
up vote
0
down vote
favorite
I'm using python 2.7.x:
import datetime
...
def _log(error_level, message):
try:
d = datetime.datetime.now()
date_template = d.strftime("%Y.%m.%d - %H:%M:%S")
...
except:
sv_custom_utils.simple_exception_info()
In 99% it is running without any problems, but sometimes I get an error:
ERROR:root:
2018.11.21 - 15:58:25:
Top: file: [sv_logger.py], method: _log()
Root: file: [sv_logger.py], line 51, cause: in _log [date_template = d.strftime("%Y.%m.%d - %H:%M:%S")]
TypeError: a float is required
What could be a reason? Python is running on Ubuntu 16/18. Does that mean that d should be a float?
python-2.7
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using python 2.7.x:
import datetime
...
def _log(error_level, message):
try:
d = datetime.datetime.now()
date_template = d.strftime("%Y.%m.%d - %H:%M:%S")
...
except:
sv_custom_utils.simple_exception_info()
In 99% it is running without any problems, but sometimes I get an error:
ERROR:root:
2018.11.21 - 15:58:25:
Top: file: [sv_logger.py], method: _log()
Root: file: [sv_logger.py], line 51, cause: in _log [date_template = d.strftime("%Y.%m.%d - %H:%M:%S")]
TypeError: a float is required
What could be a reason? Python is running on Ubuntu 16/18. Does that mean that d should be a float?
python-2.7
I'm using python 2.7.x:
import datetime
...
def _log(error_level, message):
try:
d = datetime.datetime.now()
date_template = d.strftime("%Y.%m.%d - %H:%M:%S")
...
except:
sv_custom_utils.simple_exception_info()
In 99% it is running without any problems, but sometimes I get an error:
ERROR:root:
2018.11.21 - 15:58:25:
Top: file: [sv_logger.py], method: _log()
Root: file: [sv_logger.py], line 51, cause: in _log [date_template = d.strftime("%Y.%m.%d - %H:%M:%S")]
TypeError: a float is required
What could be a reason? Python is running on Ubuntu 16/18. Does that mean that d should be a float?
python-2.7
python-2.7
asked Nov 21 at 18:30
IgorZ
219518
219518
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58
add a comment |
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418448%2fpython-2-7-strftime-typeerror%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't know the cause, but this seems relevant: stackoverflow.com/a/12400584/3000206
– Carcigenicate
Nov 21 at 18:33
The code you provided is not enough to reproduce the error. Please read how to write minimal, complete, and verifiable example
– zvone
Nov 21 at 20:35
I've mentioned that in 99% of the cases it will not be reproduced. That's why I've asked about it.
– IgorZ
Nov 21 at 20:58