![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 84
Ethan1994
爱篮球的程序员~
展开
-
python学习——Numpy(1)
简介\quadNumPy系统是Python的一种开源的数值计算扩展。这种工具可用来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多。也是一个用python实现的科学计算包。包括:1、一个强大的N维数组对象Array;2、比较成熟的(广播)函数库;3、用于整合C/C++和Fortran代码的工具包;4、实用的线性代数、傅里叶变换和随机数生成函原创 2015-07-29 20:24:57 · 463 阅读 · 0 评论 -
python学习——基本结构
with-as语法class controlled_execution: def __enter__(self): set things up return thing def __exit__(self, type, value, traceback): tear things downwith controlled_executio原创 2015-09-12 15:12:59 · 560 阅读 · 0 评论 -
python学习——yield
本文参考关于Python中的yield 在介绍yield前有必要先说明下Python中的迭代器(iterator)和生成器(constructor)。一、迭代器(iterator)在Python中,for循环可以用于Python中的任何类型,包括列表、元祖等等,实际上,for循环可用于任何“可迭代对象”,这其实就是迭代器迭代器是一个实现了迭代器协议的对象,Python中的迭代器协议就是有next方转载 2015-09-12 16:03:11 · 473 阅读 · 0 评论 -
python学习——collections模块
collections模块基本介绍参考廖雪峰的官方网站 我们都知道,Python拥有一些内置的数据类型,比如str, int, list, tuple, dict等, collections模块在这些内置数据类型的基础上,提供了几个额外的数据类型: namedtuple(): 生成可以使用名字来访问元素内容的tuple子类 deque: 双端队列,可以快速的从另外一侧追加和推出对象 Counter原创 2015-09-12 17:23:43 · 484 阅读 · 0 评论 -
python学习——itertools模块
count count()会创建一个无限的迭代器 cycle cycle()会把传入的一个序列无限重复下去 repeat repeat()负责把一个元素无限重复下去,不过如果提供第二个参数就可以限定重复次数 takewhile 通过takewhile()等函数根据条件判断来截取出一个有限的序列itertools提供的几个迭代器操作函数更加有用: chain chain()可以把一组原创 2015-09-13 11:03:57 · 559 阅读 · 0 评论 -
python学习——heapq模块
heapq是python中包含堆的相关操作的模块,其典型的应用就是取top K个数:import heapq nums = [1, 8, 2, 23, 7, -4, 18, 23, 42, 37, 2] print(heapq.nlargest(3, nums)) # Prints [42, 37, 23] print(heapq.nsmallest(3, nums)) # Prints [-4,原创 2015-09-12 16:26:20 · 716 阅读 · 0 评论 -
python学习——fnmatch
fnmatch 模块使用模式来匹配文件名>>> from fnmatch import fnmatch, fnmatchcase >>> fnmatch('foo.txt', '*.txt') True >>> fnmatch('foo.txt', '?oo.txt') True >>> fnmatch('Dat45.csv', 'Dat[0-9]*') True >>> names = ['Dat原创 2015-09-14 20:32:34 · 446 阅读 · 0 评论