1 class test(object): 2 def rangetest(self): 3 for i in range(2,0,-1): 4 print i 5 print i 6 i=2 7 wh...
分类:
编程语言 时间:
2014-08-18 18:27:12
阅读次数:
247
映射
import scala.collection.mutable
object HelloWorld {
def main(args: Array[String]) {
val scores = Map("Alice" -> 10, "Bob" -> 33) //构造一个不可变的Map[String,Int]
val scores2 = scala.collection....
分类:
其他好文 时间:
2014-08-18 16:24:32
阅读次数:
237
不会写重试,我用了这么个方法来 作为重试机制: def web(self): time.sleep(5) i = 0 a = self.br.current_url print a while i < 10: self.br.back() if self.br.current_url == a: i...
分类:
其他好文 时间:
2014-08-18 16:12:22
阅读次数:
213
一、函数的定义:Python中使用def关键字定义函数,函数包括函数名称和参数,不需要定义返回类型,Python能返回任何类型:Python代码#没有返回值的函数,其实返回的是Nonedefrun(name):printname,'runing'#函数体语句从下一行开始,并且第一行必须是缩进的>>>...
分类:
编程语言 时间:
2014-08-18 15:49:23
阅读次数:
218
《programming computer vision with python 》中denoise 算法有误,从网上好了可用的代码贴上,以便以后使用。书中错误的代码:def denoise(im,U_init,tolerance=0.1,tau=0.125,tv_weight=100): m...
分类:
编程语言 时间:
2014-08-18 14:22:32
阅读次数:
429
代码如下 1 def leap_year(y): #判断是否是闰年 2 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0: 3 return True 4 else: 5 return False 6...
分类:
编程语言 时间:
2014-08-18 02:46:33
阅读次数:
229
import sysclass mergesort(): def merge_sort(self, A, p, r): if p < r: q = (p + r) / 2 self.merge_sort(A, p, q) ...
分类:
编程语言 时间:
2014-08-17 15:30:52
阅读次数:
166
#include using namespace std;#define MAX 200int dp[MAX][MAX];int f(int M,int N){ if(M>m>>n) { f(m,n); coutusing namespace std;#def...
分类:
其他好文 时间:
2014-08-17 14:14:42
阅读次数:
270
数组要点
若长度固定则使用Array,若长度可能有变化则使用ArrayBuffer;提供初始值时不要使用new;用()来访问元素;用for(elem
例子:
import scala.collection.mutable.ArrayBuffer;
object HelloWorld {
def main(args: Array[String]) {
//实现一个可...
分类:
其他好文 时间:
2014-08-16 17:10:40
阅读次数:
211
要求计算二进制(16位)的逆序,如数12345用二进制表示为: 00110000 00111001将它逆序,我们得到了一个新的二进制数: 10011100 00001100最容易想到的方法就是依次交换两端的数据,从右向左遍历数字,当i位遇到1时,将逆序数字对应的(17-i)位设为1。def r...
分类:
其他好文 时间:
2014-08-16 11:04:40
阅读次数:
223