Python's Time representation

Source: Internet
Author: User

Python's time module provides a rich range of how-to-work methods that can be used to accomplish this requirement.

Time.time (): Gets the current timestamp

Time.ctime (): String form of the current time

Time.localtime (): The Struct_time form of the current time.

Time.strftime (): Used to get the current time, you can format the time.

Note: Python formats symbols in time date (case sensitive), as shown in table 8.1.

Instructions Meaning
%a Abbreviation of the day of the week
%A Full name of the day of the week
%w Decimal indicates day of the week (value from 0-6, Sunday is 0)
%d The day ordinal of a month represented in decimal
%b Shorthand for the month
%B Full name of the month
%m The Month in decimal notation
%y Decimal year without century (values from 0 to 99)
%Y Decimal year with part of century
%H 24 Hours of production
%I 12-Hour Hour
%p Equivalent display of the local AM or PM
%M The number of minutes represented in decimal
%s Number of seconds in decimal
%f Decimal subtle, 0 padding to the left
%Z The name of the current time zone
%j The first day of the year in decimal notation
%u Number of weeks in the year (00-53), Sunday for the beginning of the week
%W Number of weeks in the year (00-53), Monday for the beginning of the week
%x Local corresponding date representation
%x Local corresponding time representation
%% % number itself

Python's Time representation

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.