|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
问题1:是哪里打错了呢,既然报错了
import re
re.search(r'(([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]\.){3}([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])', 'other192.168.1.1other')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
re.search(r'(([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]\.){3}([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])', 'other192.168.1.1other')
File "E:\pyhthon\lib\re.py", line 201, in search
return _compile(pattern, flags).search(string)
File "E:\pyhthon\lib\re.py", line 304, in _compile
p = sre_compile.compile(pattern, flags)
File "E:\pyhthon\lib\sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "E:\pyhthon\lib\sre_parse.py", line 948, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
File "E:\pyhthon\lib\sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "E:\pyhthon\lib\sre_parse.py", line 836, in _parse
raise source.error("missing ), unterminated subpattern",
re.error: missing ), unterminated subpattern at position 0
问题2:红色是一个小组,那绿色的哪个小括号是干嘛的
re.search(r'(([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]\.){3}([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])', 'other192.168.1.1other')
|
|