技术交流QQ群:1027579432,欢迎你的加入!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-03-05 16:29:12
# @Author : cdl (1217096231@qq.com)
# @Link : https://github.com/cdlwhm1217096231/python3_spider
# @Version : $Id$
import random
import datetime
Q1:输入日期,判断这一天是这一年的第几天
def dayofyear():
year = input("输入年份: ")
month = input("输入月份: ")
day = input("输入日期: ")
date1 = datetime.date(year=int(year), month=int(month), day=int(day))
date2 = datetime.date(year=int(year), month=1, day=1)
return (date1 - date2).days + 1
Q2:打乱一个已经排好序的list对象
alist = [1, 2, 3, 4, 5]
random.shuffle(alist)
print("alist:", alist)
if __name__ == '__main__':
date = dayofyear()
print("date:", date)