Python判断某一天是这一年的第几天

 时间:2024-10-13 00:20:19

1、打开桌面的pycharm程序;

Python判断某一天是这一年的第几天

3、依次点击 New > Python File新建一个python文件;

Python判断某一天是这一年的第几天

5、如图示输入如下代码:year = int(input('year:\n'))month = int(input('罪焐芡拂month:\n'))day = int(input('day:\n'))months = (0,31,59,90,120,151,181,212,243,273,304,334)if 0 <= month <= 12: sum = months[month - 1]else: print ('data error')sum += dayleap = 0if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)): leap = 1if (leap == 1) and (month > 2): sum += 1print ('it is the %dth day.' % sum)

6、将鼠标移动至该代码的标签页并右键找到如图示选项:

Python判断某一天是这一年的第几天
  • 大学生如何变得有自信
  • Python如何定义一个列表
  • 磁性材料使用的注意事项
  • Python编程:怎么计算100到200的所有素数
  • 如何在Python中删除字符串中的空格
  • 热门搜索
    摄影旅游 上海到海南旅游 拉脱维亚旅游 过年去哪里旅游比较好 小学生旅游作文 长白山旅游团 深圳市旅游 青岛旅游路线 江门大方旅游 桂林旅游网