![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
二胖_pro
这个作者很懒,什么都没留下…
展开
-
矩阵操作中的nonzero()
老规矩,贴源码解释 def nonzero(self): """nonzero indices Returns a tuple of arrays (row,col) containing the indices of the non-zero elements of the matrix. 返回包含矩阵的非零元素索引的数组(行、列)的元组 Examples -------- >原创 2020-05-10 08:00:34 · 653 阅读 · 0 评论 -
python字典:dict的方法的使用以及代码举例
字典可以通过将以逗号分隔的 键: 值 对列表包含于花括号之内来创建,例如: {‘jack’: 4098, ‘sjoerd’: 4127} 或 {4098: ‘jack’, 4127: ‘sjoerd’},也可以通过 dict 构造器来创建。 class dict(**kwarg) class dict(mapping, **kwarg) class dict(iterable, **kwarg)...原创 2020-05-07 16:18:27 · 582 阅读 · 1 评论 -
Numpy的argsort()方法
numpy.argsort(a, axis=-1, kind=None, order=None) Returns the indices that would sort an array. 返回对数组排序的索引。 Perform an indirect sort along the given axis using the algorithm specified by the kind k...原创 2020-05-07 13:59:48 · 725 阅读 · 0 评论 -
python的zip()方法
zip(*iterables) 创建一个聚合了来自每个可迭代对象中的元素的迭代器。 返回一个元组的迭代器,其中的第 i 个元组包含来自每个参数序列或可迭代对象的第 i 个元素。 当所输入可迭代对象中最短的一个被耗尽时,迭代器将停止迭代。 当只有一个可迭代对象参数时,它将返回一个单元组的迭代器。 不带参数时,它将返回一个空迭代器。 相当于:def zip(*iterables): # zi...原创 2020-05-07 13:45:04 · 274 阅读 · 0 评论 -
python内置函数sorted()参考
sorted(iterable, *, key=None, reverse=False) 根据 iterable 中的项返回一个新的已排序列表。 具有两个可选参数,它们都必须指定为关键字参数。 key 指定带有单个参数的函数,用于从 iterable 的每个元素中提取用于比较的键 (例如 key=str.lower)。 默认值为 None (直接比较元素)。 reverse 为一个布尔值。 如果...原创 2020-05-07 13:06:08 · 120 阅读 · 0 评论 -
Python之NumPy(axis=0 与axis=1)区分
axis=0代表往跨行(down),而axis=1代表跨列(across) 使用0值表示沿着每一列或行标签\索引值向下执行方法 使用1值表示沿着每一行或者列标签模向执行对应的方法 比如: import numpy as np >>>a = array([[1. , 1.21], [1. , 1. ], [0. , 0. ], [0. , 0.0...原创 2020-05-07 09:29:29 · 187 阅读 · 0 评论 -
Python中传递列表时用copy()和不用的区别
在python中,python会通过引用的方式传递所有列表,所以必须名曲的告知Python要为新的赋值变量分配新的内存,也就是用copy()方法 代码举例: """ Author:Zhengsh Time:2020/5/3 Type:案例代码 """ def main_copy(): old = [1, 2] new = old.copy() old.append(3) ...原创 2020-05-03 09:42:07 · 667 阅读 · 0 评论