error:AttributeError: partially initialized module 're' has no attribute 'match' (most likely due to a circular import)(可能循环导入了)
代码:
import re
pattern=r'mr_\w+'
string="MR_SHOP mr_shop"
re.match(pattern,string,re.I)
march1=re.match(pattern,string,re.I)
print(march1)
string="项目名称MR_SHOP mr_shop"
march1=re.match(pattern,string,re.I)
print(march1)
运行结果:
出现error:AttributeError: partially initialized module 're' has no attribute 'match' (most likely due to a circular import)
出错说是可能循环导入了,网上找了好多方法发现没用,然后在某个帖子里看到了,
解决方法:
re被循环导入了
所以可以找一下是不是有命名其他的文件也是re.py文件
我就是发现我在一个re.py文件里面导入re,这个就是导致循环引入 的罪魁祸首
只要把名字改一下就行