python练习时出现module ‘re’ has no attribute ‘match’错误

12次阅读

共计 185 个字符,预计需要花费 1 分钟才能阅读完成。

练习 python 中正则表达式,使用 import re,并且写了最简单的匹配,运行 py 文件,却提示 module ‘re’ has no attribute ‘match’ 错误。

仔细查看原因,原来是自己把 python package 写成了 re 了。

导致 python 在执行 import re 时,以为我们要他导入我自己定义的 package 呢,将包名字改成 retest,重新运行 py 文件,成功运行。

正文完
 0