其他分享
首页 > 其他分享> > 吴裕雄--天生自然Numpy库学习笔记:NumPy 从数值范围创建数组

吴裕雄--天生自然Numpy库学习笔记:NumPy 从数值范围创建数组

作者:互联网

import numpy as np
 
x = np.arange(5)  
print (x)
import numpy as np
 
# 设置了 dtype
x = np.arange(5, dtype =  float)  
print (x)
import numpy as np
x = np.arange(10,20,2)  
print (x)

import numpy as np
a = np.linspace(1,10,10)
print(a)
import numpy as np
a = np.linspace(1,1,10)
print(a)
import numpy as np
 
a = np.linspace(10, 20,  5, endpoint =  False)  
print(a)
import numpy as np
a =np.linspace(1,10,10,retstep= True)
 
print(a)
# 拓展例子
b =np.linspace(1,10,10).reshape([10,1])
print(b)

import numpy as np
# 默认底数是 10
a = np.logspace(1.0,  2.0, num =  10)  
print (a)
import numpy as np
a = np.logspace(0,9,10,base=2)
print (a)

标签:10,NumPy,print,linspace,numpy,np,import,吴裕雄,Numpy
来源: https://www.cnblogs.com/tszr/p/12228737.html