代码如下:
import re
pattern = re.compile(r’Hello’)
match = pattern.match(‘Hello cxy61!’)
print match
执行后报错:‘module’ object has no attribute ‘compile’
解决方法:
因为源文件取名为“re.py”,把源文件“re.py”换了个文件名, 不能用跟系统库同样名字.
代码如下:
import re
pattern = re.compile(r’Hello’)
match = pattern.match(‘Hello cxy61!’)
print match
执行后报错:‘module’ object has no attribute ‘compile’
解决方法:
因为源文件取名为“re.py”,把源文件“re.py”换了个文件名, 不能用跟系统库同样名字.