从一年中的某一天获取月份和该月的某一天
我有这些数据”。 年、年中的某天,并且是闰年
需要根据给定数据打印“月、日”。
year= 2020
day_oy= 357
我试过了,
if day_ in range(1,32):
new_month= "January"
elif day_ in range(32, 61):
new_month= "February"
...
else:
new_month= "December"
需要很多行。我需要用最少的线来完成它。
I have those data'.
Year, Day of the year and it's a Leap year
Need to print "Month, Day" from given data.
year= 2020
day_oy= 357
I tried,
if day_ in range(1,32):
new_month= "January"
elif day_ in range(32, 61):
new_month= "February"
...
else:
new_month= "December"
and it takes many lines. And I need to do it using minimum lines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
输出:
获得
DateTime对象
后,您可以以任何格式获取日期的任何详细信息。有关更多详细信息,请参阅以下文档。
https://docs.python.org/3/library/library/datetime.htetime.htetime.html
Output:
Once you get the
datetime object
, you can get any details of the date in any format.Refer to the below documentation for further details.
https://docs.python.org/3/library/datetime.html
基于此 q& a 您可能想要:
Based on this Q&A you probably want: