_sourcedstring.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:gateplugin-python 作者: GateNLP 项目源码 文件源码
def subn(self, repl, string, count=0):
        if (isinstance(repl, SourcedString) or
            isinstance(string, SourcedString)):
            result = ''
            pos = 0
            n = 0
            for match in self.pattern.finditer(string):
                result += string[pos:match.start()]
                result += repl
                pos = match.end()
                n += 1
                if count and n==count: break
            result += string[pos:]
            return result, n
        else:
            return self.pattern.subn(repl, string, count)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号