def search = { ??????? if(!params.max) params.max = 10 ??????? if(!params.offset) params.offset = 0 ??????? def searchClosure =? { ??????????? if(params.categoryNa...
分类:
其他好文 时间:
2014-07-22 08:16:36
阅读次数:
271
旧版本 新版本def my_handler(sender)def my_handler(sender, **kwargs)my_signal = object()my_signal = django.dispatch.Signal()dispatcher.connect(my_handler, m....
分类:
其他好文 时间:
2014-07-21 09:16:13
阅读次数:
199
#!/usr/bin/env python# -*- coding: utf-8 -*-import sys,reimport urllib.request,urllib.parse,http.cookiejarclass myW3(): def login(self): 'post 数据' dat...
分类:
编程语言 时间:
2014-07-21 08:22:06
阅读次数:
354
简单的二叉树的先根遍历模板的应用
class Solution:
# @param root, a tree node
# @return an integer
def hehe(self, num, root):
#再原来的基础上*10,再加上当前的root.val
num = num * 10 + root.val
...
分类:
其他好文 时间:
2014-07-20 22:45:33
阅读次数:
299
常常在做webqq机器人,可是最头痛的问题就是腾讯常常加一些验证串来防止robot,如今共享出最新的腾讯password加密算法和hash算法hash算法def webqq_hash(i, a): if isinstance(i, (str, unicode)): i = int...
分类:
Web程序 时间:
2014-07-20 22:28:19
阅读次数:
264
Description
Problem D: Power Strings
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 a...
分类:
其他好文 时间:
2014-07-20 09:39:37
阅读次数:
263
myfunc=wrapper(myfunc)是一种很常见的修改其它函数的方法。从python2.4开始,可以在定义myfunc的def语句之前写@wrapper。这些封装函数就被称为装饰器Decorator,其主要用途是包装另一个函数或类。这种包装的首要目的是透明的修改或增强被包装对象的行为。1.基...
分类:
编程语言 时间:
2014-07-20 09:20:11
阅读次数:
300
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, exponentiat...
分类:
其他好文 时间:
2014-07-19 23:47:19
阅读次数:
418
1:算法简单描述
给定训练数据样本和标签,对于某测试的一个样本数据,选择距离其最近的k个训练样本,这k个训练样本中所属类别最多的类即为该测试样本的预测标签。简称kNN。通常k是不大于20的整数,这里的距离一般是欧式距离。
2:python代码实现
创建一个kNN.py文件,将核心代码放在里面了。
(1) 创建数据
#创造数据集
def createDataSet():
...
分类:
其他好文 时间:
2014-07-19 23:24:39
阅读次数:
300
例如这个函数 def fab(max): n, a, b = 0, 0, 1 while n < max: yield b # print b a, b = b, a + b n = n + 1 简单地讲,yield 的...
分类:
编程语言 时间:
2014-07-19 23:15:12
阅读次数:
247