
python
kdzc
中科院程序员一枚,研究僧在读中,主要方向压缩感知,图像处理,和大家一起学习进步^_^
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python - sort排序函数
在此顺便记录一下python中list的排序函数sort。sort函数原形如下:sorted(data, cmp=None, key=None, reverse=False) 其中,data是待排序数据,可以使List或者iterator, cmp和key都是函数,这两个函数作用与data的元素上产生一个结果,sorted方法根据这个结果来排序。 cmp(e1, e2) 是带两个原创 2015-01-31 18:36:18 · 976 阅读 · 0 评论 -
一点关于python的小感悟
写了一段时间的python发现,如果之前学习过c这种传统性语言的话,怎么写python都带有c的影子,一些其实很简单的事情,自己总是按照c的思想写,所以觉得python真的适合自己第一门学习的语言,这样再写起来会很方便。(也因为自己写的太少,净给自己写的不好找理由。。)原创 2015-04-05 16:46:03 · 702 阅读 · 0 评论 -
Repeated DNA Sequences - LeetCode
Repeated DNA Sequences - LeetCode题目:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identi原创 2015-03-24 20:38:39 · 567 阅读 · 0 评论 -
Longest Substring Without Repeating Characters - LeetCode
Longest Substring Without Repeating Characters - LeetCode题目:分析:原创 2015-03-24 18:41:01 · 487 阅读 · 0 评论 -
Two Sum - LeetCode
Two Sum - LeetCode题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that t原创 2015-03-24 20:11:12 · 525 阅读 · 0 评论 -
python - 测量程序运行时间 + 一个对于列表的小实验
在 中,我提到了在函数传递参数为list的时候,list 与list[:]是不同的,并且list[:]看起来比较快,所以我做了一个测量这个传参过程的小实验。首先说一下用来测量时间得timeit模块(大家可以放弃以前time模块了!)timeit 模块定义了接受两个参数的 Timer 类。两个参数都是字符串。 第一个参数是你要计时的语句或者函数。 传递给 Timer 的第二个参数是为第一原创 2015-03-29 20:59:21 · 1376 阅读 · 0 评论 -
3Sum - LeetCode
3Sum - LeetCode题目:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:El原创 2015-03-27 19:53:36 · 567 阅读 · 0 评论 -
Anagrams - LeetCode
Anagrams - LeetCode题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.分析:首先解释anagrams的含义:anagram解释为回文构词法,即代码:原创 2015-03-26 14:10:42 · 572 阅读 · 0 评论 -
python - numpy 基础的小总结
在通常的数据处理过程中,一般都是把数据放在列表里,再转换成矩阵来进行处理。例子:>>> from numpy import *>>> list = [1,2,3]>>> matrix = mat(list)>>> matrixmatrix([[1, 2, 3]])矩阵转置:>>> matrix.transpose()matrix([[1], [2],原创 2015-02-10 17:17:55 · 723 阅读 · 0 评论 -
第一次写博客-python编码问题
想想这辈子第一次写博客,心里还有点小激动呢~ 在写python的爬虫代码时,发现找出的中文会被编码成类似 \u4e16\u7ae0 这样的,网上有人解释可以通过import sysreload(sys)sys.setdefaultencoding('gbk')的方法来解决。但是当使用re.findall函数在网页代码找到自己需要的东西时,输出的列表还是乱码。例如conte原创 2014-12-29 10:58:02 · 675 阅读 · 0 评论 -
完全用Python工作
本文引用地址:http://blog.sciencenet.cn/blog-417402-748485.html 转载请注明来自科学网博客,并请注明作者姓名第一天, 太初有道, 神谕, import light, 于是便有光. (Quick fact: 在python解释器里输入import antigravity有彩蛋)作为一个业余物转载 2014-12-30 20:44:50 · 2442 阅读 · 0 评论 -
Python如何拉平(flatten)嵌套列表(nested list)
有时候会用到嵌套的列表(list),比如[1, 2, [3, 4, [5, 6]], ["abc", "def"]] 如果将嵌套的列表拉平(flatten)呢?变成:[1, 2, 3, 4, 5, 6, "abc", "def"] 方法有很多,目前了解到的各方面都比较好,也很pythonic的方法是:def flatten(l): for el in l:转载 2015-01-03 14:06:50 · 8030 阅读 · 0 评论 -
python 语法笔记 - extend 和 append 保持列表层次
假如存在两个列表a,b:>>>a = [1,2,3]>>>b = [4,5,6]使用append添加b时:>>>a.append(b)>>>a[1,2,3,[4,5,6]]而使用extend添加b时,会得到一个包含a和b所有元素的列表:>>>a.extend(b)>>>a[1,2,3,4,5,6]原创 2015-02-06 16:42:09 · 772 阅读 · 0 评论 -
人脸识别算法-特征脸方法(Eigenface)及python实现
这几天无聊,正好想起来以前谁说有同学做人脸识别,感觉好高大上,所以找来一些基础的人脸识别算法来自己实现一下,正好锻炼一下numpy的使用。特征脸方法基本是将人脸识别推向真正可用的第一种方法,了解一下还是很有必要的。特征脸用到的理论基础PCA我在这里就不说了,百度一大堆,主要讲一下实现步骤和自己在用python实现是发现的问题。这里我所使用的训练图片是YALE的人脸数据库点击打开链接,这里面有1原创 2015-06-08 20:15:20 · 38240 阅读 · 25 评论