python
tangtang5156
这个作者很懒,什么都没留下…
展开
-
python数据持久存储:pickle模块的基本使用
python的pickle模块实现了基本的数据序列和反序列化。通过pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,永久存储;通过pickle模块的反序列化操作,我们能够从文件中创建上一次程序保存的对象。 基本接口: pickle.dump(obj, file, [,protocol]) 注解:将对象obj保存到文件file中去。 protoc转载 2014-09-11 17:01:37 · 290 阅读 · 0 评论 -
numpy函数tile用法
tile函数位于python模块 numpy.lib.shape_base中,他的功能是重复某个数组。比如tile(A,n),功能是将数组A重复n次,构成一个新的数组,原创 2014-09-09 17:02:53 · 430 阅读 · 0 评论 -
python-切片操作符
中括号之间的冒号意思为:[start:stop:step]原创 2014-09-10 14:30:44 · 506 阅读 · 0 评论 -
python strip()
函数原型 声明:s为字符串,rm为要删除的字符序列 s.strip(rm) 删除s字符串中开头、结尾处,位于 rm删除序列的字符 s.lstrip(rm) 删除s字符串中开头处,位于 rm删除序列的字符 s.rstrip(rm) 删除s字符串中结尾处,位于 rm删除序列的字符 注意: 1. 当rm为空时,默认删除空白符(包括'\n', '\r',转载 2014-09-10 10:53:57 · 260 阅读 · 0 评论 -
python sort
sorted 和sort 的区别在于sort是在原位排序,而sorted原创 2014-09-10 09:02:37 · 331 阅读 · 0 评论 -
python--array
1 array.shape[0]是array的行数, array.shape[1]是array的列数 2原创 2014-09-09 17:32:01 · 376 阅读 · 0 评论 -
python map
map是python的应用于序列的内置函数map原创 2014-09-12 11:04:14 · 565 阅读 · 0 评论 -
python numpy.nonzero
numpy.nonzero(a) Return the indices of the elements that are non-zero. Returns a tuple of arrays, one for each dimension of a, containingthe indices of the non-zero elements in that dimension. The转载 2014-09-12 16:29:16 · 2080 阅读 · 0 评论 -
python copy()
Python中的对象之间赋值时是按引用传递的,如果需要拷贝对象,需要使用标准库中的copy模块.转载 2014-09-15 10:02:52 · 348 阅读 · 0 评论 -
python初学
决策树通过把实例从根节点排列到某个叶子节点来分类实例。原创 2014-09-05 12:14:28 · 324 阅读 · 0 评论 -
python中read() readline()以及readlines()用法
我们谈到“文本处理”时,我们通常是指处理的内容。Python 将文本文件的内容读入可以操作的字符串变量非常容易。文件对象提供了三个“读”方法: .read()、.readline() 和 .readlines()。每种方法可以接受一个变量以限制每次读取的数据量,但它们通常不使用变量。 .read() 每次读取整个文件,它通常用于将文件内容放到一个字符串变量中。然而 .read() 生成文件内容最直转载 2014-09-10 10:45:24 · 342 阅读 · 0 评论 -
Python中的sorted函数以及operator.itemgetter函数 【转载】
operator.itemgetter函数 operator模块提供的itemgetter函数用于获取对象的哪些维的数据,参数为一些序号(即需要获取的数据在对象中的序号),下面看例子。 a = [1,2,3] >>> b=operator.itemgetter(1) //定义函数b,获取对象的第1个域的值 >>> b(a) 2 >>> b=operator.itemge转载 2014-09-10 09:57:22 · 247 阅读 · 0 评论 -
python 列表推导
顾名思义,就是利用列表来创建新的列表原创 2014-09-11 15:23:10 · 279 阅读 · 0 评论 -
python遇到问题
1 ValueError: only 2 non-keyword arguments accepted 可能是listhuozh原创 2014-09-09 16:31:58 · 733 阅读 · 0 评论