pythonprint什么时候缩进_在Python中使用print()时如何包装和缩进长行?

我正在使用Python从Web服务收集数据.数据本身是一个将呈现给用户的列表.我已经设法将它打印出来像:

( 1) Example of strings

( 2) Example 4

( 3) Another Example

( 4) Another Example 2

我正在使用rjust(2)来表示数字.但是,如果线条很长,打印就会像.断开宽度是终端的长度(rxvt,gnome-terminal):

( 1) Example of a very very very very long string and

that doesn't look fine

( 2) Example of indented long line that is very very

long, example line

( 3) Another Example

( 4) Another Example of a very very long string and

whatever here is

但我想要的是打印出来像:

( 1) Example of a very very very very long string and

that doesn't look fine

( 2) Example of indented long line that is very very

long, example line

( 3) Another Example

( 4) Another Example of a very very long string and

whatever here is

有没有想法如何打印如上所述的线条而不会手动分解线条?

解决方法:

标签:python,indentation,printing,wrap

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值