python中的装饰器可以装饰函数,也可以装饰类,功能是向函数或者类添加一些功能。类似于设计模式中的装饰模式,它可以把装饰器的功能实现部分和装饰部分分开,避免类中或者函数中冗余的代码。
装饰器装饰函数:
def decrator(f1):
def newf():
print "strings will be connected:"
print f1();
return newf;...
分类:
编程语言 时间:
2014-07-28 00:21:15
阅读次数:
299
题意:求给定字符串最大循环次数
思路:根据KMP算法的next数组知,一个长度为n的字符串,
if(n%(n-next[n])==0)
最小循环长度为 L=n-next[n];
最大循环次数为 S=n/L=n/(n-next[n]);...
分类:
其他好文 时间:
2014-07-26 15:28:52
阅读次数:
182
E -Power StringsTime Limit:3000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusPracticePOJ 2406DescriptionGiven two strings a and b we ...
分类:
其他好文 时间:
2014-07-26 14:10:16
阅读次数:
201
package?main
import?(
"crypto/aes"
"fmt"
"strings"
)
func?main()?{
//////////////------AES加密------//////////////
//秘钥?16/24/32bytes对应AES-128/AES-192/AES-256.
key?:=?[]byte{
1...
分类:
其他好文 时间:
2014-07-26 03:38:37
阅读次数:
291
B. Power StringsTime Limit: 3000msMemory Limit: 65536KB64-bit integer IO format:%lld Java class name:MainGiven two strings a and b we define a*b to be...
分类:
其他好文 时间:
2014-07-26 01:25:26
阅读次数:
300
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-07-26 00:23:26
阅读次数:
242
1、IOS程序名称国际化 1.1 新建一个Single View app模版项目,命名为Localization。 1.2 新建后,可以看到工作目录结构文件如下,单击InfoPlist.strings,查看右边的属性,在Localization栏添加语言。 ? ?? 1....
分类:
移动开发 时间:
2014-07-25 00:04:34
阅读次数:
322
Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法思路:模拟二进制加法,跟十进制木有区别,将a,b转置(不转置的话,倒着...
分类:
其他好文 时间:
2014-07-24 22:57:23
阅读次数:
216
最近项目中用用到语言切换功能,第一想到的就是资源文件,没错。 在资源文件中新建一个文件夹values-en,en表示英语,有一些还细化到地区,如values-en-rUS 即美国地区的英语,r是必需的。在里面新建一个strings.xml,把默认values文件夹中的strings.xml中的内容C...
分类:
移动开发 时间:
2014-07-24 22:50:43
阅读次数:
251
一. redis
Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes
http...
分类:
其他好文 时间:
2014-07-24 10:32:58
阅读次数:
223