autonum.py 文件源码

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

项目:simugate 作者: innovation-plantation 项目源码 文件源码
def get(word):
    '''
    make the word unique by appending a numbered suffix as necessary
    :param word: such as 'foo'
    :return: word with suffix such as 'foo_1'
    '''
    # global words
    # if word not in words:
    #     words.add(word)
    #     return word

    root = rootword(word)  # word if len(chop)>1 and not chop[1].isdigit() else chop[0]
    for n in itertools.count(1):
        candidate = '%s_%d' % (root, n)
        if candidate in words: continue
        words.add(candidate)
        return candidate
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号