python每次处理一个字符的三种方法 a_string = "abccdea" print 'the first' for c in a_string: print ord(c)+1 print "the second" result = [ord(c)+1 for c in a_string] print result print "the thrid" def do_something(c): return ord(c)+1 result
用Python写了一个postgresql函数,感觉很爽 CREATE LANGUAGE plpythonu; postgresql函数 CREATE OR REPLACE FUNCTION myfun1(text) RETURNS text AS $BODY$ s = args[0] h = 0; n = len(s); for i, c in enumerate(s): h = h + ord(c)*31**(n-1-i); bits = 4*8; return (h +
经常希望可以执行一个命令行N次...windows下没有现成的工具(有?推荐给我!) 用python写一个... #!/usr/bin/evn python #coding: utf-8 """ times.py run a command line for n times """ import os import sys import string if __name__ == "__main__": n = 1 cmd =