Python Simple format Time method "Strftime function" _python

Source: Internet
Author: User

This article describes the Python simple format of the time of the method, shared for everyone to refer to, specifically as follows:

Walker often uses the current time and relative time to count the efficiency of the program's execution, simply by remembering it for easy copy.

>>> Import Time
>>> starttime = Time.time ()
>>> '%.2fs '% (Time.time ()-StartTime) #相 On time
' 24.51s '
>>> ' {:. 2f}s '. Format (Time.time ()-starttime) #相对时间
' 37.55s '
>>> Time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (time.time)) #格式化当前时间
' 2016-01-05 10:34:06 '

PS: This site also provides a UNIX timestamp conversion tool (summary of the various common language timestamp operation), very practical, to provide you with reference to:

Unix timestamp (timestamp) conversion tool:
Http://tools.jb51.net/code/unixtime

More information about Python-related content can be viewed in this site: "Python date and time operation tips Summary", "Python URL operation tips Summary", "Python picture operation Tips", "python data structure and Algorithms tutorial", "python A summary of socket programming tips, a summary of Python function usage tips, a summary of Python string manipulation tips, Python introductory and Advanced classic tutorials, and Python file and directory how-to tips

I hope this article will help you with Python programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.