text.py 文件源码

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

项目:pscheduler 作者: perfsonar 项目源码 文件源码
def prefixed_wrap(prefix, text, width=None, indent=0):
    """
    Wrap text with a prefix and optionally indenting the second and
    later lines.  If the width is None, the terminal size will be
    used.  (See terminal_size() for details.)
    """

    if width is None:
        height, width = terminal_size()

    wrapped = textwrap.wrap(text, width - len(prefix))
    leader = " " * (len(prefix) + indent)
    lines = [wrapped.pop(0)]
    lines.extend(["%s%s" % (leader, line)
                  for line in wrapped])

    return "%s%s" % (prefix, "\n".join(lines))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号