永发信息网

python限制每行长度

答案:1  悬赏:50  手机版
解决时间 2021-03-31 13:14
  • 提问者网友:你给我的爱
  • 2021-03-30 15:21
python限制每行长度
最佳答案
  • 五星知识达人网友:山君与见山
  • 2021-03-30 16:09
python标准库中的模块 textwrap 可以满足你的要求。示例:
>>> S = "It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife."
>>> print(textwrap.fill(S, width=30))
It is a truth universally
acknowledged, that a single
man in possession of a good
fortune, must be in want of a
wife.追问谢谢!可是还有别的方法吗?
我们没教这个
只可以用教过的方法><追答那么你们教过enumerate这个函数么?
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯