python
我比青菜高
这个作者很懒,什么都没留下…
展开
-
python 驻留机制
>>> s1 = '111'>>> s2 = '111'>>> s3 = "111">>> id(s1)2385244511728>>> id(s2) 2385244511728>>> id(s3) 2385244511728>>> s4 = '''111''' >>> id(s4)2385244511728但是>>>原创 2022-04-23 16:13:09 · 645 阅读 · 0 评论 -
python 二维list
由于python副本是浅拷贝;不复制嵌套结构。采用[[0] * 5] * 3时:[0]*5不会出现问题但由于[[0] * 5]中最外层list存储的是[0]*5的引用,复制3次后,每一层都会引用[0]*5,改变一个别的也会变。>>> a = [[0]*5]*3>>> a[0][0]=3>>> a[[3, 0, 0, 0, 0], [3, 0, 0, 0, 0], [3, 0, 0, 0, 0]]构建二维list时应当:>&g原创 2022-04-12 16:03:58 · 5050 阅读 · 0 评论 -
【python数据结构的哈希】
哈希不可哈希:可变的数据结构如 list,dict,set可哈希:数字、字符串、(只含数字、字符串的)touple>>> b{1: 2, 3: 4, 0: 1, 2: 1}>>> hash(b)Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: unhashable type: 'dict'>>>.原创 2022-04-08 20:50:05 · 1210 阅读 · 0 评论 -
对元素排序并取前n小值的index
ipdb> m array([[ 3, 3, 3, 15], [ 3, 18, 17, 16], [ 5, 12, 17, 10]])ipdb> np.argsort(m, axis = 0)原创 2020-07-24 22:10:03 · 99 阅读 · 0 评论 -
python(杂)不定时更新
cuda上面的变量类型只能是tensor,不能是其他原创 2020-07-10 16:41:52 · 162 阅读 · 0 评论 -
查看ndarray的数据类型
A.dtype>>>A.dtype>>>dtype('float64') #输出结果原创 2020-07-03 17:22:13 · 1072 阅读 · 0 评论