码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
八皇后问题
语言:python 1 # state[0] = 1 to represent a queen 2 # state = (1,3,0,2) 3 # * Q * * 4 # * * * Q 5 # Q * * * 6 # * * Q * 7 def conflict(state, nextX): 8....
分类:其他好文   时间:2014-08-05 18:21:09    阅读次数:221
python装饰器实现线程同步
import threading def tryfinally(finallyf):   u"returns a decorator that adds try/finally behavior with given no-argument call in the finally"   print "tryfinally"   def decorator(callable):     p...
分类:编程语言   时间:2014-08-05 11:17:29    阅读次数:226
Roman numerals
Roman numerals罗马数字的题目, 注意几个关键的数字即可: (100, 400, 500, 900) -> ('C', 'CD', 'D', 'CM'); (10, 40, 50, 90)->('X', 'XL', 'L', 'XC') 1 def checkio(data): 2 .....
分类:其他好文   时间:2014-08-05 11:06:19    阅读次数:232
The Flat Dictionary
The Flat Dictionary原来的代码没处理dict为空的情况 1 def flatten(dictionary): 2 #[] is a list 3 #() is a tuple 4 stack = [((), dictionary)] 5 6 res...
分类:其他好文   时间:2014-08-05 11:05:59    阅读次数:204
How to find friends
How to find friends思路简单,编码不易 1 def check_connection(network, first, second): 2 link_dictionary = dict() 3 4 for link in network: 5 dr...
分类:其他好文   时间:2014-08-05 11:02:19    阅读次数:245
Pawn Brotherhood
Pawn Brotherhood 1 alpha_table = "abcdefgh" 2 3 def safe_pawns(pawns): 4 safe_count = 0 5 6 for spawn in pawns: 7 if spawn[1] == '1'...
分类:其他好文   时间:2014-08-05 10:57:49    阅读次数:278
Xs and Os Referee
Xs and Os Referee 1 def checkio(game_result): 2 winner = 'D' 3 4 for row in game_result: 5 if row[0] == row[1] == row[2] and row[0] !...
分类:其他好文   时间:2014-08-05 10:44:19    阅读次数:286
常用的宏
//获取屏幕 宽度、高度#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)//获取系统版本#def...
分类:其他好文   时间:2014-08-05 10:43:39    阅读次数:250
使用python实现内置map,filter,reduce函数
map函数 #?-*-?coding:?cp936?-*- def?myselfmap(f,*args): ????def?urgymap(f,args): ????????if?args==[]: ????????????return?[] ????????else: ??????????...
分类:编程语言   时间:2014-08-04 21:50:28    阅读次数:239
【引用】python 静态函数 类函数 实例函数
1.关于定义类的一些奇特之处 今天在Python中定义一个类,很奇怪,不需要事先声明它的成员变量吗?暂时不知,先记录下来:classAccount(object):"一个简单的类"account_type="Basic"def__init__(self,name,balance):"初始化一个新的A...
分类:编程语言   时间:2014-08-04 21:25:17    阅读次数:351
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!