将字符串分成N个相等的部分?

将字符串分成N个相等的部分?,第1张

字符串分成N个相等的部分?

import textwrap
print textwrap.wrap(“123456789”, 2)
#prints [‘12’, ‘34’, ‘56’, ‘78’, ‘9’]

注意:小心空格等-这可能是您想要的,也可能不是。

"""Wrap a single paragraph of text, returning a list of wrapped lines.    Reformat the single paragraph in 'text' so it fits in lines of no    more than 'width' columns, and return a list of wrapped lines.  By    default, tabs in 'text' are expanded with string.expandtabs(), and    all other whitespace characters (including newline) are converted to    space.  See TextWrapper class for available keyword args to customize    wrapping behaviour.    """


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5653770.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存