printcalendar.py 764 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. import datetime
  3. mydate = datetime.datetime.now()
  4. mm = mydate.strftime("%B")
  5. dd = mydate.strftime("%d")
  6. yy = mydate.strftime("%Y")
  7. num = 22
  8. text = mm+" "+dd+", "+yy
  9. num2 = len(text)
  10. final = int((num-num2)*0.5)
  11. print("-"*final+text+"-"*final)
  12. print(" Su Mo Tu We Th Fr Sa ")
  13. if mm in ["January", "March", "May", "July", "August", "October", "December"]:
  14. day_num = 31
  15. elif mm in ["April", "June", "September", "November"]:
  16. day_num = 30
  17. elif mm == "Febuary":
  18. day_num = 28
  19. for i in range(1,day_num+1):
  20. if (i % 7 == 0):
  21. print(" "+str(i)+"\n",end="")
  22. elif len(str(i)) == 2:
  23. print(" "+str(i), end="")
  24. #elif str(i) == dd:
  25. # print("["+str(i)+"]",end="")
  26. else:
  27. print(" "+str(i)+" ", end="")