如何修复:属性错误:'NoneType'对象没有属性"开始"?



我有一个问题与我的python代码。问题出在这一行:

match = re.search(pattern, bytes).start()

但是我得到这个错误…我希望你能帮助我。

我认为代码应该是这样的:

match = re.search(pattern, bytes) 

if match != None:        
print("Match at index %s, %s" % (match.start(), match.end()))        
else: 
print("The regex pattern does not match.")

希望能帮到你。

相关内容

最新更新