python输入某年某月某日歌词_python求输入某年某月某日,判断这一天是这一年的第几天...
方法一:
"""
3、输入某年某月某日,判断这一天是这一年的第几天
"""
year = int(input("请输入年分:"))
month = int(input("请输入月份:"))
day = int(input("请输入日:"))
count = 0
if month == 1:
count = day
elif month == 2:
count = 31 + day
elif month == 3 and ((year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)):
if month == 3:
count = 31 + 29 + day
if month == 4:
count = 31 + 29 + 31 + day
if month == 5:
count = 31 + 29 + 31 + 30 + day
if month == 6:
count = 31 + 29 + 31 + 30 + 31 + day
if month == 7:
count = 31 + 29 + 31 + 30 + 31 + 30 + day
if month == 8:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day
if month == 9:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + day
if month == 10:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day
if month == 11:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day
if month == 12:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day
else:
if month == 3:
count = 31 + 28 + day
if month == 4:
count = 31 + 28 + 31 + day
if month == 5:
count = 31 + 28 + 31 + 30 + day
if month == 6:
count = 31 + 28 + 31 + 30 + 31 + day
if month == 7:
count = 31 + 28 + 31 + 30 + 31 + 30 + day
if month == 8:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day
if month == 9:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day
if month == 10:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day
if month == 11:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day
if month == 12:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day
print("公共%d天" % count)
方法二:
print("-" * 20)
import datetime
result = datetime.datetime(year, month, day)
# 用来格式化时间,%j 用来表示天数
print(result.strftime("%j"))
方法三:
"""
3、输入某年某月某日,判断这一天是这一年的第几天
"""
year = int(input("请输入年分:"))
month = int(input("请输入月份:"))
day = int(input("请输入日:"))
print("-" * 20)
day += (month-1) * 30
if month < 9:
day += month//2
else:
day += (month+1)//2
if month > 2:
if year%400 ==0 or year%4 == 0 and year%100 !=0 :
day -= 1
else:
day -= 2
print("是一年的第%d天"%day)
python输入某年某月某日歌词_python求输入某年某月某日,判断这一天是这一年的第几天...相关推荐
- python怎么输入一个数字并调用_Python求输入一个整数,然后输出这个整数的所有数字:个位数字在前,高位数字在后,中间使用空格字符连接...
附件程序enumeratenumber.py使用数字整除的方式实现了该功能,使用字符串实现该功能的代码没有完成.请仔细阅读代码之后,写出完整代码.[附加]enumeratenumber.py实现的输出 ...
- python实现不重复排列组合_Python实现输入字符串,返回其任意排列组合
在脉脉上看到的一道算法题,要求如下图: 以下是用Python实现这一算法: def str_rank_combination(s=""): """输入 ...
- python怎样连续输入两个数字_python实现输入数字的连续加减
不用库,写了很久,一直出bug,到网上一搜,可以直接输入之后,eval(str)即可得到结果! eval程序如下: s=input("请输入要运算的数字") print(" ...
- python输入数字并求和_Python如何输入数字并求和
输入数字并求和作为Python基础知识,又难倒了一批小伙伴.今天我们以案例为分析,帮助大家更好的理解和运用. 以下实例为通过用户输入两个数字,并计算两个数字之和: # -*- coding: UTF- ...
- python输入4个数字_Python中输入任意四个数,输出他们由大到小排序
Python中输入任意四个数,输出他们由大到小排序 Python中输入任意四个数,输出他们由大到小排序 要方便的那种,谢谢! 第1个回答 2018-11-04 任意输入4个整数,从大到小排列输出.c语 ...
- python输入数字并排序_Python 对输入的数字进行排序的方法
要求,输入一串数字,并以列表的形式打印出来. number = input('请输入一串数字:') print(number) print(type(number)) 假设输入12345,得到结果如下 ...
- python怎么定义整数数组_python中输入整数数组长度python基础语法
变量 数字类型 运算符 流程控制 while循环 dead loop continue vs break while else 变量(Varibles) W WW.002pc .COM认为此文章对&l ...
- python同时输入多个字符串_Python之输入两个字符串,输出字符串并集
题目: 输入两个字符串,输出两个字符串集合的并集. 例如:接受的两个字符串为"abc"和"bcd",返回['a', 'b', 'c' , 'd'] 思考: 1. ...
- python文件中数字排序_Python 对输入的数字进行排序的方法
{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],&q ...
- python输出100以内偶数_Python求取100以内的所有偶数和奇数以及和
使用Python求取100以内的所有偶数和奇数以及和,是Python的一道基础练习题目,刚好在看Python4.0学习手册第十三章循环,觉得挺有意思,就想了下这道题目的代码,想到两种方式. # cod ...
最新文章
- 腾讯云智能制造首次披露三大战略布局,发布“511”生态伙伴计划
- 终极对决!Dubbo 和 Spring Cloud 微服务架构到底孰优孰劣?
- Linux下通过设置PS1变量改变bash提示符颜色
- vue better-scroll 使用 下拉刷新、上拉加载
- 21种mysql_让MySQL飞起来!别小看这21种写SQL的好习惯
- pubmed影响因子插件_新版新版PubMed使用技巧2
- 对排名前3000位博主进行数据分析
- Code Signal_练习题_evenDigitsOnly
- 现在出纳记账手写还是用计算机,请问:出纳现金日记账和银行日记账是否一定要用手写归档能否用电脑打印归档?...
- 六祎-网易云视频下载
- 十代主板改win7_微星z490主板装win7系统及bios设置教程(支持10代cpu装win7)
- 一键安装ROS和rosdep(NO 墙)
- 听我给你普及师父、师傅和讲师、教师的区别
- idea显示Multiple Spring Boot run configurations were detected. Services allows to manage multiple run
- 微信公众平台消息管理与群发图文教程
- 转载: Lodop、C-Lodop打印控件报错
- 使用深山红叶工具盘备份瘫痪服务器的数据
- C# 调用打印机 打印 Excel
- FPC软排线结构的奥秘
- sqlserver2008 R2数据库-不允许表修改保存,阻止保存要求重新创建表的更改