码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
K60——寄存器
(1)PTx_BASE_PTR为GPIO寄存器结构体基址指针(PTR即point to register,x=A/B/C/D/E)/* GPIO - Peripheral instance base addresses *//** Peripheral PTA base pointer */#def...
分类:其他好文   时间:2015-01-15 20:05:52    阅读次数:382
Gradle 创建Web项目
apply plugin: 'java'apply plugin: 'war'apply plugin: 'eclipse-wtp'apply plugin: 'maven' def projectName = "finance-site"version = '0.0.1-SNAPSHOT'sour...
分类:Web程序   时间:2015-01-15 17:31:06    阅读次数:154
数据类型检查
数据类型检查可以用内置函数isinstance实现:1 def my_abs(x):2 if not isinstance(x, (int, float)):3 raise TypeError('bad operand type')4 if x >= 0:5 ...
分类:其他好文   时间:2015-01-15 12:35:54    阅读次数:165
《大话设计模式》ruby版代码:外观模式
需求:股民买卖股票初步代码:# -*- encoding: utf-8 -*-#股票1class Stock1 def buy puts '股票1买入' end def sell puts '股票1卖出' endend#股票2class S...
分类:其他好文   时间:2015-01-14 22:43:20    阅读次数:177
python学习之self,cls,staticmethod,classmethod
一、总体说明python类里会出现这三个单词,self和cls都可以用别的单词代替,类的方法有三种,一是通过def定义的 普通的一般的,需要至少传递一个参数,一般用self,这样的方法必须通过一个类的实例去访问,类似于c++中通过对象去访问;二是在def前面加上@classmethod,这种类方法的...
分类:编程语言   时间:2015-01-14 19:43:17    阅读次数:170
python中的commands模块,执行出错:'{' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
最近发现了python的commands模块,查看了下源码,使用的popen封装的,形成三个函数getstatus(), getoutput(), getstatusoutput()源码如下:def getstatus(file): """Return output of "ls -ld " ...
分类:编程语言   时间:2015-01-14 11:01:40    阅读次数:1094
《大话设计模式》ruby版代码:模板方法模式
需求:学生抄题目,做题目初始代码# -*- encoding: utf-8 -*-#学生甲的试卷类class TestPaperA def question1 puts '杨过得到,后来给了郭靖,炼成倚天剑,屠龙刀的玄铁可能是[] a.球墨铸铁 b.马口铁 c.高速合金...
分类:其他好文   时间:2015-01-13 23:14:41    阅读次数:250
python高级编程-Part3 修饰器前奏
修饰器用来包装函数,增加额外的功能,而且应能够修饰一批函数,减少代码重用。简单的修饰器一个函数接收函数对象作为参数,并且返回函数对象,这样的函数可以成为一个修饰器,形如下面的定义:defdeco(func): def_deco(*args): print"dosomething" func(*args) return_deco上..
分类:编程语言   时间:2015-01-13 20:04:18    阅读次数:313
Python特殊语法--filter、map、reduce、lambda
一、filter(function, sequence)对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回:def f(x): return x % 2 != 0 a...
分类:编程语言   时间:2015-01-13 19:32:01    阅读次数:207
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!