试一下bbcode贴代码,很快会把方法放上来

试一下bbcode贴代码,很快会把方法放上来

Python代码: Gravatar in python
01  # import code for encoding urls and generating md5 hashes
02  import urllib , hashlib
03
04  # Set your variables here
05  email = "someone@somewhere.com"
06
07  default = "http://www.somewhere.com/homsar.jpg"
08  size = 40
09
10  # construct the url
11  gravatar_url = "http://www.gravatar.com/avatar.php?"
12
13  gravatar_url += urllib . urlencode ({ 'gravatar_id' : hashlib . md5 ( email ) . hexdigest (),
14      'default' : default , 'size' : str ( size )})

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
JavaScript代码: RGB颜色值转HTML十六进制(HEX)代码的JS函数
01  //转到固定长度的十六进制字符串,不够则补0
02  function zero_fill_hex(num, digits) {
03    var s = num.toString( 16);
04    while (s.length < digits)
05     s =  "0" + s;
06    return s;
07 }
08
09  //妈的,怎么都没搜到怎么用javascript找出一个背景色的数值,只好自己解析
10  function rgb2hex(rgb) {
11    var n = Number(rgb);
12    var ds = rgb.split( /\D+/);
13    var decimal = Number(ds[ 1]) *  65536 + Number(ds[ 2]) *  256 + Number(ds[ 3]);
14    return zero_fill_hex(decimal,  6);
15 }

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
看上去很不错的样子,顶一个把。。。
顶一个