码迷,mamicode.com
首页 >  
搜索关键字:python module    ( 144473个结果)
python中的装饰器
python中的装饰器能够装饰函数,也能够装饰类,功能是向函数或者类加入?一些功能。类似于设计模式中的装饰模式,它能够把装饰器的功能实现部分和装饰部分分开,避免类中或者函数中冗余的代码。装饰器装饰函数:def decrator(f1): def newf(): print "strings w...
分类:编程语言   时间:2014-08-12 18:26:44    阅读次数:257
Python笔记:替代case语句的字典和匿名函数(lambda)
在linux的shell中我们习惯使用case语句来做分支处理,然而Python中却省略了这个函数,经过多方查找,发现其实case语句在C语言中是通过查对应的hash表,来进行跳转的。在Python中我们可以通过三种方法来实现这种功能。1、字典;2、lambda;3、switch类。1、字典dictCase={‘case1..
分类:编程语言   时间:2014-08-12 17:41:15    阅读次数:487
python模块收集
shutil:用于拷贝目录树、删除目录树,类似os.remove/os.rmdirfnmatch:通过shellglob去匹配字符串、文件名
分类:编程语言   时间:2014-08-12 17:38:45    阅读次数:152
在python中使用logging模块
importlogging logging.basicConfig(level=logging.INFO,filename=‘mylog.log‘) logging.info(‘Startingprogram‘) logging.info(‘Tryingtodivide1by0‘) print1/0 logging.info(‘Thedivisionsucceeded‘) logging.info(‘Endingprogram‘)
分类:编程语言   时间:2014-08-12 17:36:35    阅读次数:202
python学习之类的继承
面向对象中一个重要的特性就是继承,继承的好处就是提高代码的重用率,减少不必要的代码。继承是父类与子类的关系,当子类继承了父类后,就具有了父类的所有变量和方法。在python中定义继承的语法是:class派生类名(基类名)。在使用python的继承时需要注意一下几点:(1)当..
分类:编程语言   时间:2014-08-12 17:36:15    阅读次数:209
python冒泡排序
def bubble_sort(list):     for i in range(len(list)):         for j in (range(i,len(list))):             if list[j]                 temp = list[j]                 list[j] = list[i]...
分类:编程语言   时间:2014-08-12 17:27:54    阅读次数:216
Numpy 中tile(A, reps)方法
numpy中tile(A,reps)详细解释...
分类:其他好文   时间:2014-08-12 17:27:04    阅读次数:189
python选择排序
def select_sort(list): for i in range(len(list)): position = i for j in range(i,len(list)): if list[position] > list[j]: position = j temp = list[i] list[i] = list[position] list[pos...
分类:编程语言   时间:2014-08-12 17:25:34    阅读次数:236
python插入排序
def insert_sort(list): for i in range(len(list)): while i > 0 and list[i] < list[i-1]: temp = list[i] list[i] = list[i-1] list[i-1] = temp i = i-1...
分类:编程语言   时间:2014-08-12 17:25:24    阅读次数:269
import 语句的模块顺序
核心风格: import 语句的模块顺序       我们推荐所有的模块在 Python 模块的开头部分导入。 而且最好按照这样的顺序: 1.Python 标准库模块 2. Python 第三方模块 3. 应用程序自定义模块       然后使用一个空行分割这三类模块的导入语句。 这将确保模块使用固定的习惯导入, 有助于减少每个模块需要的 import 语句数目。       解释器执...
分类:其他好文   时间:2014-08-12 17:17:04    阅读次数:189
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!