python pprint_Python学习路线之Beeprint怎么用

v2-678ac7ed00b43905b396dc09bd4cb149_1440w.jpg?source=172ae18b

Python学习路线之Beeprint怎么用,beeprint:让你的调试打印更友好

推荐一个国人的开源项目 beeprint,可以更加漂亮的打印你的调试信息。对标 Python 标准库的 pprint。

下面我们就来看一下 beeprint 和 pprint 打印 Python 对象的对比。

打印字典对象

pprint

python

{'entities': {'hashtags': [],
              'urls': [{'display_url': 'tumblr.com/xnr37hf0yz',
                        'expanded_url': 'http://tumblr.com/xnr37hf0yz',
                        'indices': [107, 126],
                        'url': 'http://t.co/cCIWIwg'}],
              'user_mentions': []}}

beeprint

python

{
  'entities': {
    'hashtags': [],
    'urls': [
      {
        'display_url': 'tumblr.com/xnr37hf0yz',
        'expanded_url': 'http://tumblr.com/xnr37hf0yz',
        'indices': [107, 126],
        'url': 'http://t.co/cCIWIwg',
      },
    ],
    'user_mentions': [],
  },
}

```

打印类对象

pprint

python

<class 'definition.NormalClassNewStyle'>

beeprint

python

class(NormalClassNewStyle):
  dicts: {
  },
  lists: [],
  static_props: 1,
  tupl: (1, 2)

打印实例(instance)

pprint

python

<definition.NormalClassNewStyle object at 0x7f338e5a9dd0>

beeprint

python
instance(NormalClassNewStyle):
  dicts: {
  },
  lists: [],
  say_hi: 'hello world',
  static_props: 1,
  tupl: (1, 2)

打印长文本

pprint

```python

[['nThe sky and the earth were at first one blurred entity like an egg. Pangu was born into it.n ntThe separation of the sky and the earth took eighteen thousand years-the yang which was light and pure rose to become the sky, tand the yin which was heavy and murkyxefxbcx88xe6x9cxa6xe8x83xa7xe7x9ax84xefxbcx89 sank to form the earth. Between them was Pangu, who went through nine tchanges every day, his wisdom greater than that of the sky and his ability greater than that of the earth. Every day the sky rose ten feet higher, the earth became ten feet thicker, and Pangu grew ten feet taller.n nAnother eighteen thousand years passed, and there was an extremely high sky, an extremely thick earth, and an extremely tall Pangu. After Pangu died, his head turned into the Five Sacred Mountains (Mount Tai, Mount Heng, Mount Hua, Mount Heng, Mount Song), his eyes turned into the moon and the sun, his blood changed into water in river and sea, his hair into grass.n nIn all, the universe and Pangu combine in one.n',

'nxe6x8dxaexe6xb0x91xe9x97xb4xe7xa5x9exe8xafx9dxe4xbcxa0xe8xafxb4xe5x8fxa4xe6x97xb6xe7x9bx98xe5x8fxa4xe7x94x9fxe5x9cxa8xe9xbbx91xe6x9ax97xe5x9bxa2xe4xb8xadxefxbcx8cxe4xbbx96xe4xb8x8dxe8x83xbdxe5xbfx8dxe5x8fx97xe9xbbx91xe6x9ax97xefxbcx8cxe7x94xa8xe7xa5x9exe6x96xa7xe5x8ax88xe5x90x91xe5x9bx9bxe6x96xb9xefxbcx8cxe9x80x90xe6xb8x90xe4xbdxbfxe5xa4xa9xe7xa9xbaxe9xabx98xe8xbfx9cxefxbcx8cxe5xa4xa7xe5x9cxb0xe8xbexbdxe9x98x94xe3x80x82ntxe4xbbx96xe4xb8xbaxe4xb8x8dxe4xbdxbfxe5xa4xa9xe5x9cxb0xe4xbcx9axe9x87x8dxe6x96xb0xe5x90x88xe5xb9xb6xefxbcx8cxe7xbbxa7xe7xbbxadxe6x96xbdxe5xb1x95xe6xb3x95xe6x9cxafxe3x80x82xe6xafx8fxe5xbdx93xe7x9bx98xe5x8fxa4xe7x9ax84xe8xbaxabxe4xbdx93xe9x95xbfxe9xabx98xe4xb8x80xe5xb0xbaxefxbcx8cxe5xa4xa9xe7xa9xbaxe5xb0xb1xe9x9ax8fxe4xb9x8bxe5xa2x9exe9xabx98xe4xb8x80xe5xb0xbaxefxbcx8cntxe7xbbx8fxe8xbfx871.8xe4xb8x87xe5xa4x9axe5xb9xb4xe7x9ax84xe5x8axaaxe5x8ax9bxefxbcx8cxe7x9bx98xe5x8fxa4xe5x8fx98xe6x88x90xe4xb8x80xe4xbdx8dxe9xa1xb6xe5xa4xa9xe7xabx8bxe5x9cxb0xe7x9ax84xe5xb7xa8xe4xbaxbaxefxbcx8cxe8x80x8cxe5xa4xa9xe7xa9xbaxe4xb9x9fxe5x8dx87xe5xbex97xe9xabx98xe4xb8x8dxe5x8fxafxe5x8fx8axefxbcx8cxe5xa4xa7xe5x9cxb0xe4xb9x9fxe5x8fx98xe5xbex97xe5x8ex9axe5xaex9exe6x97xa0xe6xafx94xe3x80x82xe7x9bx98xe5x8fxa4xe7x94x9fxe5x89x8dxe5xaex8cxe6x88x90xe5xbcx80xe5xa4xa9xe8xbex9fxe5x9cxb0xe7x9ax84xe4xbcx9fxe5xa4xa7xe4xb8x9axe7xbbxa9xefxbcx8cxe6xadxbbxe5x90x8exe6xb0xb8xe8xbfx9cxe7x95x99xe7xbbx99xe5x90x8exe4xbaxbaxe6x97xa0xe7xa9xb7xe6x97xa0xe5xb0xbdxe7x9ax84xe5xaex9dxe8x97x8fxefxbcx8cxe6x88x90xe4xb8xbaxe4xb8xadxe5x8dx8exe6xb0x91xe6x97x8fxe5xb4x87xe6x8bx9cxe7x9ax84xe8x8bxb1xe9x9bx84xe3x80x82n']]

```

beeprint

python
[
  [
    'nThe sky and the earth were at first one blurred entity like an egg. Pangu
     was born into it.n ntThe separation of the sky and the earth took
     ...(12 hidden lines)',
    'n据民间神话传说古时盘古生在黑暗团中,他不能忍受黑暗,用神斧劈向四方,逐渐
 使天空高远,大地辽阔。nt他为不使天地会重新合并,继续施展法术。每当盘古的
     ...(3 hidden lines)',
  ],
]

怎么样,用 beeprint 来打印我们的 Python 对象是不是给我们开发调试带来了方便呢?

快来安装体验以下吧。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值