from datetime import datetime,timedelta #导入datetime,timedeltaa=datetime.today() #获取当前日期b=datetime.now() #获取当前日期时间print(a,b)print(b,b.minute) #输出当前日期时间及分钟c=datetime(2013,4,9) #生成指定日期print(a-c) #输出日期差print(a + timedelta(hours=72))print(a + timedelta(days=100))print(a - timedelta(weeks=2))a=list(range(10)) #生成范围1-10列表(注意:a,b两个列表长度要一致,否则会出错)b=list(range(0,50,5))c=[] #定义一个空列表for i in range(len(a)): #对列表进行循环遍历 c.append(a[i]+b[i]) print(a,b,c)def pySum(n): #定义一个函数(注意:格式对齐,否则会出错) a=list(range(n)) b=list(range(0,50*n,5)) c=[] for i in range(len(a)): c.append(a[i]**2+b[i]**3) return(c) print(pySum(20))import numpy #导入库numpya=numpy.arange(10) #生成数组b=numpy.arange(0,50,5)c=a+bprint(a,b,c)print(type(a))def npSum(n): #定义一个函数(注意:格式对齐,否则会出错) a = numpy.arange(10) b=numpy.arange(0,50*n,5) c=[] for i in range(len(a)): c.append(a[i]**2+b[i]**3) return(c) print(npSum(20))from datetime import datetimestart=datetime.now()pySum(1000) #计算出时间间隔delta=datetime.now()-startprint(delta)start=datetime.now()npSum(1000)delta=datetime.now()-startprint(delta)