小马过_河

导航

2018年2月23日 #

shell 修改工作路径

摘要: import os os.getcwd() #查看现路径 os.chdir('新路径') #修改路径 阅读全文

posted @ 2018-02-23 15:41 小马过_河 阅读(347) 评论(0) 推荐(0) 编辑

把目录C:\Python34\PCI_Code\chapter2\加到系统路径中

摘要: >>> import sys >>> sys.path.append("C:\Python34\PCI_Code\chapter2") 阅读全文

posted @ 2018-02-23 15:39 小马过_河 阅读(241) 评论(0) 推荐(0) 编辑

2018年1月30日 #

twoSum

摘要: 1 def twoSum(nums, target): 2 d = {} 3 for i, num in enumerate(nums): 4 if target - num in d: 5 return (d[target-num], i) 6 d[num] = i 阅读全文

posted @ 2018-01-30 21:33 小马过_河 阅读(144) 评论(0) 推荐(0) 编辑

归并排序

摘要: 空间复杂度为O(n),时间复杂度为O(nlogn)。稳定性:稳定缺点:每次拆分数组都要开心的数组, 每次合并数组都要开新数组,空间复杂度很大 def merge_sort( li ): #不断递归调用自己一直到拆分成成单个元素的时候就返回这个元素,不再拆分了 if len(li) == 1: return li #取拆分的中间位置 mid = ... 阅读全文

posted @ 2018-01-30 15:10 小马过_河 阅读(173) 评论(0) 推荐(0) 编辑

2017年12月28日 #

numpy.array

摘要: 关于python中的二维数组,主要有list和numpy.array两种。 好吧,其实还有matrices,但它必须是2维的,而numpy arrays (ndarrays) 可以是多维的。 我们主要讨论list和numpy.array的区别: 我们可以通过以下的代码看出二者的区别 list对应的索 阅读全文

posted @ 2017-12-28 15:15 小马过_河 阅读(481) 评论(0) 推荐(0) 编辑

python.numpy.std()计算矩阵标准差

摘要: 1 >>> a = np.array([[1, 2], [3, 4]]) 2 >>> np.std(a) # 计算全局标准差 3 1.1180339887498949 4 >>> np.std(a, axis=0) # axis=0计算每一列的标准差 5 array([ 1., 1.]) 6 >>> np.std(a, axis=1) # 计算每一行的标准差 7 arr... 阅读全文

posted @ 2017-12-28 15:11 小马过_河 阅读(24818) 评论(0) 推荐(0) 编辑