[Python] python根据开头和结尾字符串获得指定字符串的中间字符串 →→→→→进入此内容的聊天室

来自 , 2020-12-15, 写在 Python, 查看 153 次.
URL http://www.code666.cn/view/d98d76e2
  1. def GetMiddleStr(content,startStr,endStr):
  2.     startIndex = content.index(startStr)
  3.     if startIndex>=0:
  4.         startIndex += len(startStr)
  5.     endIndex = content.index(endStr)
  6.     return content[startIndex:endIndex]
  7.  
  8. if __name__=='__main__':
  9.     print(GetMiddleStr('<div class="a">sharejs.com</div>','<div class="a">','</div>'))
  10.  
  11.  
  12. #//python/8476

回复 "python根据开头和结尾字符串获得指定字符串的中间字符串"

这儿你可以回复上面这条便签

captcha