码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
积累 自定义 Python 函数
简单爬虫常用#获取网络内容def getWebContent(url): headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko)...
分类:编程语言   时间:2014-12-11 12:02:33    阅读次数:181
pyqt练习x5
#-*-coding:cp936-*-importsysfromPyQt4importQtGui,QtCoreclassMainWindow(QtGui.QMainWindow):def__init__(self,parent=None):QtGui.QMainWindow.__init__(sel...
分类:其他好文   时间:2014-12-10 22:37:49    阅读次数:194
getattr,setattr
#!/usr/bin/env python# !-*-coding:utf-8-*-class Setting(): name = "asdfa" age = "18" def __init__(self): passclass MyClass(): def _...
分类:其他好文   时间:2014-12-10 21:06:21    阅读次数:197
python中使用hasattr(x,'call')来判断一个对象是否存在某个方法
class Person: def PrintName(self): print 'Is a Person' def PrintHello(self): print 'Hello, world'per = Person()per.PrintName()print hasa...
分类:编程语言   时间:2014-12-10 21:02:10    阅读次数:222
python 迭代器
迭代器使用方法:#!/usr/bin/env python# !-*-coding:utf-8-*-__author__ = 't'class anyIter(object): def __init__(self, li): self.li =iter(li) def __...
分类:编程语言   时间:2014-12-10 19:46:12    阅读次数:175
Ruby类,模块1
类的扩展和继承class Fixnum def dosome(str) puts str end def abs puts "覆盖了原有的方法" endendputs 1.class1.dosome("动态添加的方法")1.abs#覆盖原有的方法 freeze冻结对象class ...
分类:其他好文   时间:2014-12-10 19:34:00    阅读次数:250
Scala关于变长参数
Scala语言中,如果方法的参数不确定个数,则可以使用变长参数,例如:def sum(args:Int*): Int ={ var result = 0 for(arg <- args) result += arg result }调用方法如下:sum(1,2,3,4,5,6)s...
分类:其他好文   时间:2014-12-10 15:58:38    阅读次数:395
二叉树顺序结构实现/链式结构实现
程杰《大话数据结构》这部分的源码乱起八糟的。自己总结下: 顺序结构: #include "stdafx.h" #include "string.h" #include "stdio.h" #include "stdlib.h" #include using namespace std; #define ok 1 #define error 0 #def...
分类:其他好文   时间:2014-12-10 12:36:40    阅读次数:226
Python学习笔记1209
将string中有元音字母的去掉,replace 函数1 def anti_vowel(text):2 for i in text:3 if i in "aeiouAEIOU":4 text=text.replace(i,'')5 return...
分类:编程语言   时间:2014-12-10 00:27:02    阅读次数:311
计算程序运行时间
摘自Cookbook: 1 #!/usr/bin/env python 2 import time 3 def timeo(fun, n=1000): 4 def void( ): pass 5 start = time.clock( ) 6 for i in range...
分类:其他好文   时间:2014-12-09 21:23:54    阅读次数:148
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!