How to get the current time in Python

前端 未结 30 1433
滥情空心
滥情空心 2020-11-22 06:47

What is the module/method used to get the current time?

30条回答
  •  攒了一身酷
    2020-11-22 07:18

    If you just want the current timestamp in ms (for example, to measure execution time), you can also use the "timeit" module:

    import timeit
    start_time = timeit.default_timer()
    do_stuff_you_want_to_measure()
    end_time = timeit.default_timer()
    print("Elapsed time: {}".format(end_time - start_time))
    

提交回复
热议问题