AttributeError: 'module' object has no attribute 'fullmatch'.
来源:互联网 发布:武汉淘宝美工培训学校 编辑:程序博客网 时间:2024/06/06 14:26
报错
跑代码的时候遇到了 AttributeError
:
AttributeError: 'module' object has no attribute 'fullmatch'.
经过查找,发现出错的原因是 re库
中的 fullmatch函数
是 在py3.4之后才新添加的 。
解决方案
自己写一个接口,然后调用该接口即可。
一般会把自己新写的接口放在 utils.py
文件里。在该文件中加上以下代码段:
import re# Backport Python 3.4's regular expression "fullmatch()" to Python 2def fullmatch(regex, string, flags=0): """Emulate python-3.4 re.fullmatch().""" return re.match("(?:" + regex + r")\Z", string, flags=flags)
接着在原本 调用 re.fullmatch
接口 的地方 替换 为 调用 utils.fullmatch
接口 即可。
阅读全文
0 0
- AttributeError: 'module' object has no attribute 'fullmatch'.
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute 'LabelMap'
- AttributeError: 'module' object has no attribute 'XXX'
- AttributeError: 'module' object has no attribute 'urlopen'
- AttributeError:'module' object has no attribute 'classify'
- AttributeError: ‘module’ object has no attribute’xxx’
- AttributeError: ‘module’ object has no attribute’ 问题
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute 'AF_INET'
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute '_base'
- AttributeError: 'module' object has no attribute 'best_partition'
- 自定义view 仿即刻APP炫酷的点赞效果
- 块定义typedef void (^ SuccesBlock)(id object)
- iTOP-4412开发板利用官网提供的Ubuntu编译zImage烧入开发板后,不断重启的解决方法
- 14个你可能不知道的JavaScript调试技巧
- opencv_tutorial_code学习——画椭圆、圆、填充矩形、直线
- AttributeError: 'module' object has no attribute 'fullmatch'.
- 服务器访问次数限制实现的思路
- C++11 多线程 future/promise简介
- UML建模之时序图(Sequence Diagram)
- Xcode Search Paths相关配置
- python基础-socket初识、udp通信、udp数据报协议
- SpringMVC conflicts with existing, non-compatible bean definition of same name and class 的解决办法,sprin
- 五、C#学习基础篇---事件
- Java后台重定向