Getting milliseconds in Python

John Hunter jdhunter at ace.bsd.uchicago.edu
Wed Feb 16 11:19:37 EST 2005


>>>>> "mjs7231" == mjs7231  <mjs7231 at gmail.com> writes:

    mjs7231> This is no good, I am looking for milliseconds, not
    mjs7231> seconds.. as stated above.

Well seconds/1000.0 = millseconds -- or are you worries about floating
point error?

7 >>> from datetime import datetime
8 >>> dt = datetime.now()
9 >>> dt.microsecond
Out[9]: 20222

Converting to milliseconds is left as an exercise for the reader...

See also the timeit module...


JDH



More information about the Python-list mailing list