12 2021 档案

摘要:os.path 模块 主要用于获取文件的属性 例如: os.path.dirname(path) 功能:去掉文件名,返回目录 print(os.path.dirname("E:/Read_File/read.py")) #结果: E:/Read_File os.path.abspath(__file 阅读全文
posted @ 2021-12-09 12:37 KYZH 阅读(57) 评论(0) 推荐(0) 编辑
摘要:原博主:python脚本中的sys.path.append("..")详解 - 习久性成 - 博客园 (cnblogs.com) import import xxx 默认情况下Python解析器会搜索当前目录、已安装的内置模块和第三方模块,搜索路径存放在sys模块的path中 sys.path.ap 阅读全文
posted @ 2021-12-08 22:08 KYZH 阅读(833) 评论(0) 推荐(0) 编辑
摘要:输入为矩阵x输出为形状和x一致的矩阵,其元素全部为0 >>> import numpy as np >>> a=np.arange(12) >>> a=a.reshape(2,2,3) >>> a array([[[ 0, 1, 2], [ 3, 4, 5]], [[ 6, 7, 8], [ 9, 阅读全文
posted @ 2021-12-08 21:46 KYZH 阅读(406) 评论(0) 推荐(0) 编辑
摘要:常用于矩阵求和计算 格式: np.sum(a)np.sum(a, axis=0) >列求和np.sum(a, axis=1) >行求和 In : a = np.array([[0, 2, 1], [3, 5, 6], [0, 1, 1]]) #得到一个矩阵a In : a.sum() #将a中所有元 阅读全文
posted @ 2021-12-08 20:41 KYZH 阅读(256) 评论(0) 推荐(0) 编辑
摘要:import numpy as np c=np.array([1,2,3]) d=np.array([[1,2,3],[4,5,6],[7,8,9]]) e=np.array([[[1,2,3],[4,5,6],[7,8,9]]]) c.ndim # 1 d.ndim # 2 e.ndim # 3 阅读全文
posted @ 2021-12-04 16:08 KYZH 阅读(208) 评论(0) 推荐(1) 编辑
摘要:it = np.nditer(x, flags=['multi_index'], op_flags=['readwrite']) while not it.finished: # ... it.iternext() np.nditer:有效的多维迭代器对象,可以遍历数组。 参数(部分): op:nd 阅读全文
posted @ 2021-12-04 16:02 KYZH 阅读(234) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示