Python Forum

Full Version: this is inconsitent with documentation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
the strftime() method has a single common documentation for the two modules (datetime and time) it is found in, but ...
Output:
lt1/forums /home/forums 1> py3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import datetime,time >>> datetime.datetime.now().strftime('%f') '754235' >>> time.strftime('%S%f') '26%f' >>> lt1/forums /home/forums 2> py2 Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime,time >>> datetime.datetime.now().strftime('%f') '390678' >>> time.strftime('%S%f') '02%f' >>> lt1/forums /home/forums 3>
There is no %f formater for time.strftime().

https://docs.python.org/2/library/time.h...e.strftime
(Jan-16-2017, 06:17 AM)wavic Wrote: [ -> ]There is no %f formater for time.strftime().

https://docs.python.org/2/library/time.h...e.strftime

the pdf docs document both in the same place, which implies that both are the same whether they have %f (defined by posix) or not. it doesn't really say for sure, but it provides the posix table, implying by that, that we can expect posix stuff to work.

it would be nice if python worked with nanoseconds.  but the layer below it (still) does a poor job.
what exactly is inconsistent with documentation? The output is from two different dates, at different times of the day
If you want it as a number, use time.time().