好程序员-千锋教育旗下高端IT职业教育品牌

400-811-9990
我的账户
好程序员

专注高端IT职业培训

亲爱的猿猿,欢迎!

已有账号,请

如尚未注册?

  • 客服QQ
  • 官方微信

    好程序员

    专注高端IT职业培训

好程序员Python培训分享Beeprint怎么用

[复制链接]
32 0
叶子老师 发表于 前天 14:31 | 只看该作者 |阅读模式 打印 上一主题 下一主题
好程序员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 \n\tThe 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 murky\xef\xbc\x88\xe6\x9c\xa6\xe8\x83\xa7\xe7\x9a\x84\xef\xbc\x89 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',
```
beeprint
```python
[
  [
    '\nThe sky and the earth were at first one blurred entity like an egg. Pangu
     was born into it.\n \n\tThe separation of the sky and the earth took
     ...(12 hidden lines)',
    '\n据民间神话传说古时盘古生在黑暗团中,他不能忍受黑暗,用神斧劈向四方,逐渐
     使天空高远,大地辽阔。\n\t他为不使天地会重新合并,继续施展法术。每当盘古的
     ...(3 hidden lines)',
  ],
```
怎么样,用 beeprint 来打印我们的 Python 对象是不是给我们开发调试带来了方便呢?
快来安装体验以下吧。
好程序员Python培训官网:http://obomdaqui.com/python_class.shtml

精彩内容,一键分享给更多人!
收藏
收藏0
转播
转播
分享
淘帖0
支持
支持0
反对
反对0
回复

使用道具 举报

您需要登录后才可以回帖

本版积分规则

关注我们
千锋好程序员

北京校区(总部):北京市海淀区宝盛北里西区28号中关村智诚科创大厦

深圳西部硅谷校区:深圳市宝安区宝安大道5010号深圳西部硅谷B座A区605-619

杭州龙驰智慧谷校区:浙江省杭州市下沙经济技术开发区元成路199号龙驰智慧谷B座7层

郑州校区:郑州市二七区航海中路60号海为科技园C区10层、12层

Copyright 2007-2019 北京千锋互联科技正规体育投注 .All Right

京ICP备12003911号-5 京公安网11010802011455号

请您保持通讯畅通1对1咨询马上开启