1、错误描述
E:PycharmProjectscmnvenvScriptspython.exe E:/PycharmProjects/cmn/venv/com.you.cmn/L.py
Traceback (most recent call last):
File "E:/PycharmProjects/cmn/venv/com.you.cmn/L.py", line 3, in <module>
a = re.match("@","454545@qq.com").span();
AttributeError: 'NoneType' object has no attribute 'span'
Process finished with exit code 1
2、错误原因
在匹配@时,不是以这个开头,调用span()出现None.span(),出现报错
import re;
a = re.match("@","454545@qq.com").span();
print(a);
3、解决办法
(1)如果后面匹配不是以前面的字符,不使用span()
import re;
a = re.match("@","454545@qq.com");
print(a);
(2)以某个字符开头,调用span()
import re;
a = re.match("@","@454545@qq.com").span();
print(a);