码迷,mamicode.com
首页 > 其他好文 > 详细

numpy

时间:2018-10-22 13:00:34      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:padding   pac   app   pen   order   code   nta   cin   今天   

1、处理日期时间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import datetime
print(datetime.datetime.now())
print("--------------------------------")
from datetime import datetime,timedelta
now = datetime.now()
print(now)
print("--------------------------------")
dt = datetime(2019,10,22,8,59)
print(dt)
print("--------------------------------")
cday=datetime.strptime(‘2015-6-1 18:19:59‘,‘%Y-%m-%d %H:%M:%S‘)
print(cday)
print("--------------------------------")
now1 =now.strftime(‘%a, %b %d %H:%M‘)
print(now1)
print("--------------------------------")
print(‘今天是{0:%y}年的第{0:%j}天。‘.format(now))
print("--------------------------------")
print(dt-now)
print("--------------------------------")

 

2.

数列:a = a1,a2,a3,·····,an  ;    b = b1,b2,b3,·····,bn

求:c = a12+b13,a22+b23,a32+b33,·····+an2+bn3

 

import numpy as py

from datetime import datetime
 
def listSum(n):
    a=list(range(n))
    b=list(range(0,5*n,5))
    c=[]
    for in range(len(a)):
     c.append(a[i]**2+b[i]**3)
    return c
 
 
def numpySum(n):
    a=py.arange(n)
    b=py.arange(0,5*n,5)
    c=a**2+b**3
    return c
 
now1=datetime.now()
print(listSum(1000000))
now2=datetime.now()
print(now2-now1)
 
 
now3=datetime.now()
print(numpySum(1000000))
now4=datetime.now()
print(now4-now3)
 

numpy

标签:padding   pac   app   pen   order   code   nta   cin   今天   

原文地址:https://www.cnblogs.com/chjh/p/9829227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!