Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the functions of Python's time library

Shulou Source: shulou.com Published: 2022-06-01 04:58:07 10月27日 Update

Most people do not understand the knowledge points of this article, "how to use the functions of Python's time library", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Python's time library functions how to use" article.

Some functions of time Library

Time.time ():

Get the current timestamp, that is, the internal time value of the computer, floating point number

Time.ctime (): gets the current time and represents it in an easy-to-read way, returning a string

Time.gmtime (): gets the current time, expressed as a time format that can be processed by the computer

Time.perf_counter ():

1. Returns the value of the performance counter in minutes and seconds, that is, the clock with the highest available resolution to measure the short duration.

two。 It includes time elapsed during sleep and within the system.

3. The reference point of the return value is not defined, so only the difference between the results of successive calls is valid.

Note: 1Jue 2 indicates the accuracy of the return value of the method and what parts the return value includes, while 3 indicates that the method is only one call is meaningless and needs to be called two or more times to be valid.

Time.sleep (seconds): let the program stagnate here for seconds seconds

Time formatting:

Srtftime (tpl,ts) format template-tpl ts-computer internal time type variable (that is, the return value of time.gmtime ())

Example:

Strptime (str,tpl): converts str into computer internal time type variables by template

The above is about the content of this article on "how to use the functions of Python's time library". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Time content function computer format valid variable article method template knowledge article type highest accurate between value minute and second resolution unit Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno macOS MariaDB Linux