按某课程写的,非原创
import numpy as np
def main():
lst=[[1,2,3,4,5],[3,4,5,6,7]]
np_lst=np.array(lst,dtype=float)
print(type(lst))
print(type(np_lst))
print(np_lst.shape)
print(np_lst.size)
print(np_lst.dtype)
print(np.zeros([2,4]))
print(np.ones([3,5]))
print('Rand:')
print(np.random.rand(2,4))#随机生成2*4矩阵,元素为介于[0,1]之间的均匀分布小数
print(np.random.rand())
print('Rand-Int:')
print(np.random.randint(1,10))
print(np.random.randint(1,10,3))
print('Randn:')
print(np.random.randn(2,4))#随机生成2*4矩阵,元素为介于[0,1]之间的标准正态分布小数
print(np.random.randn())
print('Choice:')
print(np.random.choice([1,4,6,8]))
print('Distribute:')
print(np.random.beta(1,10,15))#随机生成15个元素,其中元素符合beta分布且介于[1,10]
if __name__ =="__main__":
main()