irc.py 文件源码

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

项目:hostapd-mana 作者: adde88 项目源码 文件源码
def split(str, length = 80):
    """I break a message into multiple lines.

    I prefer to break at whitespace near str[length].  I also break at \\n.

    @returns: list of strings
    """
    if length <= 0:
        raise ValueError("Length must be a number greater than zero")
    r = []
    while len(str) > length:
        w, n = str[:length].rfind(' '), str[:length].find('\n')
        if w == -1 and n == -1:
            line, str = str[:length], str[length:]
        else:
            i = n == -1 and w or n
            line, str = str[:i], str[i+1:]
        r.append(line)
    if len(str):
        r.extend(str.split('\n'))
    return r
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号