摘要: l = map(chr, xrange(256)) #将ascii转为字符串_idmap = str('').join(l)del l# Construct a translation string_idmapL = None #定义一个全局变量def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.trans 阅读全文
posted @ 2013-07-18 15:49 践道者 阅读(589) 评论(0) 推荐(0) 编辑
摘要: def capwords(s, sep=None): """capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced 阅读全文
posted @ 2013-07-18 15:00 践道者 阅读(1597) 评论(0) 推荐(0) 编辑
摘要: # Some strings for ctype-style character classification c风格字符串whitespace = ' \t\n\r\v\f' #空白字符 \t 制表符 \n换行lowercase = 'abcdefghijklmnopqrstuvwxyz'uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'letters = lowercase + uppercaseascii_lowercase = lowercaseascii_uppercase = uppercaseascii 阅读全文
posted @ 2013-07-18 14:08 践道者 阅读(567) 评论(0) 推荐(0) 编辑
摘要: def make_addr(addend): def addr(augend): return augend + addend return addrp = make_addr(23)q = make_addr(42)print p(10)print q(10) 阅读全文
posted @ 2013-07-18 11:36 践道者 阅读(216) 评论(0) 推荐(0) 编辑