kaola4549 发表于 2018-8-15 10:49:10

python 输出指定年月份的日历!

#!/usr/bin/python  
#coding=utf-8
  

  
import time
  
import calendar
  
k=0
  
def nowtime():
  
    t1=time.time()
  
    localt1=time.localtime(t1)
  
    localtime=time.asctime(localt1)
  
    print localtime
  
while k<=1:
  
    k+=1
  
    time.sleep(2)
  
    nowtime()
  
for i in xrange(1,13):#12个月份
  
    print '2017年%s月的日历\n'%i,calendar.month(2017,i)    #可以更改年份
  
    time.sleep(1)
页: [1]
查看完整版本: python 输出指定年月份的日历!