How Python implements the calendar and includes running results

Source: Internet
Author: User
This article mainly for you in detail the Python calendar implementation code, including the operation results, with a certain reference value, interested in small partners can refer to

The example of this article for you to share the Python implementation of the calendar of the specific code for everyone to refer to, the specific content as follows

#coding: Utf-8def leap_year (year): #判断平瑞年  if year%4==0 and year%100!=0 or year%400==0:    return True  else:    return falsedef getmonthdays (year,month): #得到每个年份每月的天数 days  = +  If month = = 2:    if Leap_year (year):      days=29    Else:      days=28  elif month==4 or month==6 or month==9 or month==11:    days=30  return Daysdef gettotaldays (year,month): #计算星期  totaldays=0 for  i in range (1,year):    if Leap_year (i):      Totaldays + = 366    Else:      totaldays + 365 for  i in range (1,month):    totaldays +=getmonthdays (year,i) C21/>return totaldaysyear=input ("Enter year:") month = input ("Enter month:") ICount = 0print "t \ t two \ three \ four \ t five \ t Six" i=1for I in Range (( Gettotaldays (year,month)%7) +1):    print ' \ t ',    icount+=1for i in range (1,getmonthdays (year,month) +1):    Print I, ' \ t ',    iCount +=1    if icount%7 = = 0:      print '

Operating effect:

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.