Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';int';对象没有属性';匹配';当我注册exp时_Python_Python 2.7 - Fatal编程技术网

Python 属性错误:';int';对象没有属性';匹配';当我注册exp时

Python 属性错误:';int';对象没有属性';匹配';当我注册exp时,python,python-2.7,Python,Python 2.7,我试图读取一个文件,并尝试下面的regexp来查找某个特定字符串的存在,但最终出现以下错误 if re.match("(.*)hello.%s_world"%(str(what_name)), lines): 获取以下错误: AttributeError: 'int' object has no attribute 'match' 基本错误或问题可能是什么?请澄清同样的问题 更新: 当我复制同一个文件并尝试做一个小实验时,效果很好。但是当我在我的大脚本中尝试同样的方法时,我得到了上面的错误

我试图读取一个文件,并尝试下面的regexp来查找某个特定字符串的存在,但最终出现以下错误

if re.match("(.*)hello.%s_world"%(str(what_name)), lines):
获取以下错误:

AttributeError: 'int' object has no attribute 'match'
基本错误或问题可能是什么?请澄清同样的问题

更新:
当我复制同一个文件并尝试做一个小实验时,效果很好。但是当我在我的大脚本中尝试同样的方法时,我得到了上面的错误

在某个地方,您用一个数字重新定义了
re
。可能您有一个定义为name
re
的变量,该变量的值是一个整数,它与原始
re
module.OH crap。。是,在较大的脚本中有一些变量定义为re。。我会努力改正并试一试。。非常感谢您的快速评论!