# 取指定定界符中间的内容 def mid(content: str, beginString: str = '', endString: str = ''): """ 取指定定界符中间的内容 :param content: str 要截取的字符串 :param beginString: str 开始定界符 :param endString: str 结束定界符 :return: str 子串 """ if len(beginString) > 0: beginPos = content.find(beginString) if beginPos == -1: return '' else: beginPos = -1 if len(endString) == 0: if beginPos == -1: return '' return content[beginPos + 1:] endPos = content.find(endString) return content[beginPos + 1:endPos]
[原] Python 取指定定界符中间的内容
最新推荐文章于 2021-02-20 17:46:43 发布