05 2015 档案
摘要:源代码:roman_mumeral_map = (('M',1000), ('CM',900), ('D',500), ('CD',400), ('C',100), ('XC',90), ('L',50), ('XL',40), ('X',10), ('IX',9), ('V',5), ('IV',...
阅读全文
摘要:将任何字符串作为python表达式求值:eval()方法: eval(source[, globals[, locals]]) -> value Evaluate the source in the context of globals and locals. The source ma...
阅读全文
摘要:>>> import re>>> re.search('[abc]','mark')>>> re.sub('[abc]','o','Mark')'Mork'>>> re.sub('[abc]','o', 'carp')'oorp'import redef plural(noun): if re.se...
阅读全文
摘要:import re -- 所有正则表达式相关的功能都包含在re模块中re.sub() -- 字符串替换>>> import re>>> s= "100 NORTH BROAD ROAD">>> re.sub('ROAD$','RD.',s)'100 NORTH BROAD RD.'>>> s = "...
阅读全文
摘要:格式化字符串/复合字段名>>> import humansize>>> si_suffixes = humansize.SUFFIXES[1000]>>> si_suffixes['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']>>> '1000{0[0...
阅读全文
摘要:Import os; -- Python自带print(os.getcwd()) -- 获得当前工作目录os.chdir('/Users/longlong/Documents') -- 转换到/Users/longlong/Documents目录os.path.join(parm1, parm2,....
阅读全文