common.py 文件源码

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

项目:python-tutorial 作者: Akuli 项目源码 文件源码
def header_link(title):
    """Return a github-style link target for a title.

    >>> header_link('Hello there!')
    'hello-there'
    """
    # This doesn't handle multiple titles with the same text in the
    # same file, but usually that's not a problem. GitHub makes
    # links like the-title, the-title-1, the-title-2 etc.
    result = ''
    for character in title:
        if character in string.whitespace:
            result += '-'
        elif character in string.punctuation:
            pass
        else:
            result += character.lower()
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号