我们经常看到各种被双下划线环绕的方法,如__init__,它们就是魔术方法.
魔术方法是python语言预定好的"协议",不同魔术方法在不同场景下,会被隐式调用.我们通过重载这些方法,从而操控各种行为.
class A(object):
def __str__(self):
return "I am A,2333"
def __len__(self):
...
分类:
编程语言 时间:
2014-10-17 15:30:54
阅读次数:
494
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:
其他好文 时间:
2014-10-17 15:23:35
阅读次数:
148
1.model 是业务模型,数据库的增删改查都集中到model里,db = mysql::getIns(); } public function reg($data){ //db既然能被auto_Excute 说明是mysql实例 return $this->db->autoExcute($t...
分类:
其他好文 时间:
2014-10-17 15:18:34
阅读次数:
230
好题,也非常有用,犯了几个错误1.在枚举赋值的时候,思维有个错误:当当前的赋值不能填完这个数独,应该是继续下一个循环,而不是return false 终止枚举2.Generic Programing写错了,,,本来那个memset想写成Generic Programing的,,,然后,永远仅仅有第一...
分类:
其他好文 时间:
2014-10-17 13:43:36
阅读次数:
191
Problem:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integer...
分类:
其他好文 时间:
2014-10-17 13:33:42
阅读次数:
179
/** * 将时间戳转为代表"距现在多久之前"的字符串 * @param timeStr 时间戳 * @return */ public static String getStandardDate(String timeStr) { ...
分类:
移动开发 时间:
2014-10-17 13:27:40
阅读次数:
227
/***代码参考来自:http://www.oschina.net/code/snippet_778481_21907*只验证身份证是否正确,未加上判断性别*@param num 身份证号码*@return boolean true|false*使用,var bools = checkIdentit...
分类:
Web程序 时间:
2014-10-17 13:23:22
阅读次数:
183
水题一道,不加优化也能0MS#include #include #include #include #include using namespace std;int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int Power(i...
分类:
其他好文 时间:
2014-10-17 13:18:32
阅读次数:
180
题意:有N个黑点和N个白点,每个黑点只能水平向右和竖直向下延伸,与一个白点配对。权值为两个点之间的曼哈顿距离。求使得n对点均配对最小的配对总权值。
思路:假设存在一组解,那么我们交换一对配对,若依旧能够满足条件,画画图就知道答案不变。
因此对于任意可行配对答案均相同。
于是我们统计出所有黑点的-x+y,所有白点的x-y,累加起来即可。
Code:#include
#inc...
分类:
其他好文 时间:
2014-10-17 12:06:07
阅读次数:
147
============问题描述============ 现在有一个需求,就是一个界面如下ABCA固定在顶部,C固定在底部其中B是一个scrollview(也可能是listview),要实现,在向上滑动B的时候,A平滑的往上滑,同时C平滑的往下滑,直到消失,在向下滑动B的时候,A平滑的往下滑,C平滑...
分类:
其他好文 时间:
2014-10-17 11:44:10
阅读次数:
188