Python Date & Time

來源:互聯網
上載者:User

標籤:char   mod   highlight   line   import   ace   column   imp   current   

1. time module

import timetime.time() #The function time.time() returns the current system time in ticks since 12:00am, January 1, 1970(epoch).time.asctime([tupletime]) #Accepts a time-tuple and returns a readable 24-character string such as ‘Tue Dec 11 18:07:14 2008‘.time.localtime([secs]) #Accepts an instant expressed in seconds since the epoch and returns a time-tuple t with the local time (t.tm_isdst is 0 or 1, depending on whether DST applies to instant secs by local rules).

  

2. calendar module

import calendarcalendar.calendar(year,w=2,l=1,c=6)#Returns a multiline string with a calendar for year #year formatted into three columns separated by c spaces. #w is the width in characters of each date; each line has length 21*w+18+2*c. #l is the number of lines for each week.calendar.firstweekday( )#Returns the current setting for the weekday that starts each week.#By default, when calendar is first imported, this is 0, meaning Monday.calendar.isleap(year)#Returns True if year is a leap year; otherwise, False.calendar.month(year,month,w=2,l=1)#Returns a multiline string with a calendar for month month of year year, #one line per week plus two header lines. #w is the width in characters of each date; each line has length 7*w+6. #l is the number of lines for each week.

  

Python Date & Time

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.