码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
pyqt最小化学习
#-*-coding:cp936-*-#!/usr/bin/envpython#-*-coding:utf-8-*-fromPyQt4importQtCore,QtGuiclassWindow(QtGui.QMainWindow):def__init__(self):super(Window,sel...
分类:其他好文   时间:2014-10-04 18:35:57    阅读次数:184
pyqt sender()学习
#!/usr/bin/python#-*-coding:utf-8-*-#sender.pyimportsysfromPyQt4importQtGui,QtCoreclassExample(QtGui.QMainWindow):def__init__(self):super(Example,self...
分类:其他好文   时间:2014-10-04 17:15:36    阅读次数:794
《机器学习实战》菜鸟学习笔记(三)kNN手写识别系统
目的:利用kNN识别数字0-9材料:32*32的数字方阵(保存形式是文本文件)#-*-coding:utf-8-*-from numpy import *def img2vector(filename): #生成一个1*1024的array(zeros是numpy的函数,至于array与lis...
分类:其他好文   时间:2014-10-04 02:25:05    阅读次数:234
Ruby学习之mixin
直接上代码:module Action def jump @distance = rand(4) + 2 puts "I jumped forward #{@distance} feet!" endendclass Rabbit include Action attr_reade...
分类:其他好文   时间:2014-10-03 00:29:03    阅读次数:235
Ruby学习之module
我们可以认为module是一个专门存放一系列方法和常量的工具箱。module和class非常像, 只是module不能创建实例也不能有子类, 它们仅仅能存放东西。例如:module Circle PI = 3.141592653589793 def Circle.area(radius) ...
分类:其他好文   时间:2014-10-02 23:05:23    阅读次数:282
Ruby类的继承
Ruby继承的语法class DerivedClass 用attr_reader, attr_writer读写属性(attribute)根据前面我们所学,如果想要访问定义在类中的属性,例如,我们想要访问@name实例变量, 我们必须这么写def name @nameend如果我们想要我们想修改@n....
分类:其他好文   时间:2014-10-02 22:54:03    阅读次数:276
Ruby类的创建与使用
Ruby是一种面向对象编程语言,这意味着它操纵的编程结构称为"对象"先上代码, 了解类的定义与使用方式class Computer $manufacturer = "Mango Computer, Inc." @@files = {hello: "Hello, world!"} def i...
分类:其他好文   时间:2014-10-02 18:17:43    阅读次数:154
Python的链式调用
?代码: class?Chain(object): ????def?__init__(self,?path=‘‘): ????????self._path?=?path ? ????def?__getattr__(self,?path): ????????return?Chain(‘%s/%s‘?%?(self._...
分类:编程语言   时间:2014-10-02 09:17:32    阅读次数:206
xadmin的插件机制
xadmin的视图方法中如果加了@filter_hook 标记的都可以作为插件的钩子函数。例如在ListAdminView类中有许多加了上述标记的方法, @filter_hook def get_context(self): """ Prepare the c...
分类:其他好文   时间:2014-10-02 00:34:11    阅读次数:374
partial函数-python学习
一个函数可以有多个参数,而在有的情况下有的参数先得到,有的参数需要在后面的情景中才能知道,python 给我们提供了partial函数用于携带部分参数生成一个新函数。def add(a,b,c=2): print("a is:%s b is %s c is %s"%(a,b,c)) r...
分类:编程语言   时间:2014-10-02 00:18:41    阅读次数:233
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!