摘要:
(一)正则表达式基本规则:^匹配字符串开始位置。$匹配字符串结束位置。\b匹配一个单词边界。\d匹配一个数字。\D匹配一个任意的非数字字符。x?匹配可选的x字符。换句话说,就是0个或者1个x字符。x*匹配0个或更多的x。x+匹配1个或者更多x。x{n,m}匹配n到m个x,至少n个,不能超过m个。(a|b|c)匹配单独的任意一个a或者b或者c。(x)这是一个组,它会记忆它匹配到的字符串。你可以用re.search返回的匹配对象的groups()函数来获取到匹配的值。[abc] 匹配a b c 中的一个[^abc]除了a、b或c之外的任何字符案例1:罗马数字在罗马数字中,有七个不同的数字可以以不同 阅读全文
posted @ 2013-06-27 15:49
大哉昆仑
阅读(468)
评论(0)
推荐(0)
摘要:
python引用变量的顺序: 当前作用域局部变量->外层作用域变量->当前模块中的全局变量->python内置变量1. Scope:• If a variable is assigned inside a def, it is local to that function.• If a variable is assigned in an enclosing def, it is nonlocal to nested functions.• If a variable is assigned outside all defs, it is global to the enti 阅读全文
posted @ 2013-06-27 10:35
大哉昆仑
阅读(411)
评论(0)
推荐(0)
浙公网安备 33010602011771号