[issue19475] Inconsistency between datetime's str()/isoformat() and its strptime() method
Tim Peters
report at bugs.python.org
Fri Nov 1 19:07:37 CET 2013
Tim Peters added the comment:
The decision to omit microseconds when 0 was a Guido pronouncement, back when datetime was first written. The idea is that str() is supposed to be friendly, and for the vast number of applications that don't use microseconds at all, it's unfriendly to shove ".000000" in their face all the time. Much the same reason is behind why, e.g., str(2.0) doesn't produce "2.0000000000000000".
I doubt this will change. If you want to use a single format, you could massage the data first, like
if '.' not in dt:
dt += ".000000"
----------
nosy: +tim.peters
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19475>
_______________________________________
More information about the Python-bugs-list
mailing list