import codecs
FileName = r'c:\ls\1'
#KeyStr = input("the key string: ")
KeyStr = '<dd class="info"><span>执业证号:'
FoundFlag = False
#用utf-8格式打开文件
FileObj = codecs.open(FileName, 'r', 'utf-8')
LineTemp = FileObj.readline()
while LineTemp:
# print(LineTemp)
# print(KeyStr)
# zc = LineTemp.find(KeyStr)
if LineTemp.find(KeyStr) > 0:
FoundFlag = True
print("*************************")
print("the line is: " + LineTemp, end='')
print("*************************")
LineTemp = FileObj.readline()
# break
else:
LineTemp = FileObj.readline()
FileObj.close()
if FoundFlag == False:
print("Not found the string!")