我试图搜索以下字符串中的一行字符
</Connector>
我写了以下代码。但似乎找不到这根弦。我知道这些不是元字符,因此应该自动匹配。还有,我查了一下是否有空位。但没用。谁知道我做错了什么
for line in wim_file:
if re.findall("</Connector>",line):
print('Word Found')
else:
print("Word Not Found!!")
注意:下面一行有另一个字符串不应该匹配。我需要在上面提到的字符串中匹配带“/”字符的精确字符串
<Connector some text>
编辑:请在下面找到更多的文字行
<Connector RefLabel="70100-01-L" Tolerance="1" UniqueID="WPWDH">
<Property authority="Design" name="PartNumber">H1BB</Property>
<Property authority="Design" name="Part">89</Property>
<Property authority="Design" name="ZTH">1</Property>
<Property authority="Design" name="Base">WSS Class 3</Property>
<Property authority="Design" name="PATHID">H1BB</Property>
</CoordinatedEntity>
</Connector>
对regex稍加修改就得到了所需的行
相关问题 更多 >
编程相关推荐