python随笔
zsiming
Why do we fall?
展开
-
python :赋值、深拷贝、浅拷贝的区别
昨天在Leetcode上遇见一道有关回溯算法的题目遇见了这个问题:在3处将得到的答案append到1处的res中原创 2020-09-09 18:04:52 · 133 阅读 · 0 评论 -
python-矩阵内某个小矩阵的替换
import numpy as np#原始矩阵mat = np.arange(16).reshape(4, 4)print(mat)#操作的行范围 [0~1]rows = np.arange(2)[:, np.newaxis]#操作的列范围 [0~1]cols = np.arange(2)#替换矩阵target_mat = np.array([-1, -2, -3, -4]).reshape(2, 2)#进行替换mat[rows, cols] = target_mat原创 2020-07-27 12:33:48 · 4638 阅读 · 0 评论