码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
ruby学习--block
1 #当前块 2 class Block 3 def a_method 4 return yield if block_given? 5 'no block' 6 end 7 end 8 obj=Block.new 9 puts "#{obj.a_m...
分类:其他好文   时间:2014-08-27 20:18:28    阅读次数:194
Permutations【python】
class Solution: # @param num, a list of integer # @return a list of lists of integers def permute(self, num): length=len(num) i...
分类:编程语言   时间:2014-08-27 20:11:28    阅读次数:200
ruby学习--varaible
1 #全局变量2 $global_variable=103 class Class14 def print_global()5 puts "Global variable in Class1 is #{$global_variable}"6 end7 end8 cla...
分类:其他好文   时间:2014-08-27 20:08:28    阅读次数:197
Python闭包及装饰器
Python闭包先看一个例子:def outer(x): def inner(y): return x+y return innderadd = outer(8)print add(6)我们定义了一个方法outer,方法内部又定义了一个方法inner,方法outer返回值为...
分类:编程语言   时间:2014-08-27 18:32:58    阅读次数:197
python 单例模式(依据元类)
class?Singleton2(type):???? ????def?__init__(cls,?name,?bases,?dict):???? ????????super(Singleton2,?cls).__init__(name,?bases,?dict)???? ????????cls._instan...
分类:编程语言   时间:2014-08-27 11:12:48    阅读次数:241
python实现的基于TCP的JSON数据通信
用Python写的一个多线程TCP通信实例,实现了JSON数据的传输。 闲言少述,直接上代码 ? 一、客户端 #!/usr/bin/env python # -*- coding:utf-8 -*- # import socket import threading import SocketServer import json def client(ip, port,...
分类:编程语言   时间:2014-08-27 11:01:37    阅读次数:389
Poj 2001 (Trie 前缀树)
#include #include #include #include #include #include #include #include #include #include #define MAXN 400010 #define MOD 20071027 #define INF 0x7fffffff #define EPS 1e-8 #define PI acos(-1.0) #def...
分类:其他好文   时间:2014-08-27 09:28:47    阅读次数:191
Python优先权队列出现TypeError: unorderable types 解决方法
class?MyType: ????def?__init__(self,?arg1,?arg2=None): ????????self.data1?=?arg1 ????????self.data2?=?arg2 q?=?queue.PriorityQueue() m1?=?MyType(5) m2?=?MyType(2)...
分类:编程语言   时间:2014-08-27 00:29:57    阅读次数:288
POJ1144 Network(判断割点)
题目链接“点击打开链接 判断割点的个数 #include #include #include #include #include #include const int N = 210; const int maxn = 500; const int maxm = 21010; const int inf = 1e8; #define MIN INT_MIN #def...
分类:Web程序   时间:2014-08-26 21:28:36    阅读次数:322
POJ 2406 Power Strings
Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponenti...
分类:其他好文   时间:2014-08-25 21:11:14    阅读次数:183
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!