当前位置: 首页>>代码示例>>Python>>正文


Python pprint.html方法代码示例

本文整理汇总了Python中pprint.html方法的典型用法代码示例。如果您正苦于以下问题:Python pprint.html方法的具体用法?Python pprint.html怎么用?Python pprint.html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pprint的用法示例。


在下文中一共展示了pprint.html方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _ustr

# 需要导入模块: import pprint [as 别名]
# 或者: from pprint import html [as 别名]
def _ustr(obj):
        """Drop-in replacement for str(obj) that tries to be Unicode friendly. It first tries
           str(obj). If that fails with a UnicodeEncodeError, then it tries unicode(obj). It
           then < returns the unicode object | encodes it with the default encoding | ... >.
        """
        if isinstance(obj,unicode):
            return obj

        try:
            # If this works, then _ustr(obj) has the same behaviour as str(obj), so
            # it won't break any existing code.
            return str(obj)

        except UnicodeEncodeError:
            # The Python docs (http://docs.python.org/ref/customization.html#l2h-182)
            # state that "The return value must be a string object". However, does a
            # unicode object (being a subclass of basestring) count as a "string
            # object"?
            # If so, then return a unicode object:
            return unicode(obj)
            # Else encode it... but how? There are many choices... :)
            # Replace unprintables with escape codes?
            #return unicode(obj).encode(sys.getdefaultencoding(), 'backslashreplace_errors')
            # Replace unprintables with question marks?
            #return unicode(obj).encode(sys.getdefaultencoding(), 'replace')
            # ...

    # build list of single arg builtins, tolerant of Python version, that can be used as parse actions 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:30,代码来源:pyparsing.py

示例2: pprint

# 需要导入模块: import pprint [as 别名]
# 或者: from pprint import html [as 别名]
def pprint(self, *args, **kwargs):
        """Pretty-printer for parsed results as a list, using the C{pprint} module.
           Accepts additional positional or keyword args as defined for the 
           C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint})"""
        pprint.pprint(self.asList(), *args, **kwargs)

    # add support for pickle protocol 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:9,代码来源:pyparsing.py

示例3: _ustr

# 需要导入模块: import pprint [as 别名]
# 或者: from pprint import html [as 别名]
def _ustr(obj):
        """Drop-in replacement for str(obj) that tries to be Unicode friendly. It first tries
           str(obj). If that fails with a UnicodeEncodeError, then it tries unicode(obj). It
           then < returns the unicode object | encodes it with the default encoding | ... >.
        """
        if isinstance(obj, unicode):
            return obj

        try:
            # If this works, then _ustr(obj) has the same behaviour as str(obj), so
            # it won't break any existing code.
            return str(obj)

        except UnicodeEncodeError:
            # The Python docs (http://docs.python.org/ref/customization.html#l2h-182)
            # state that "The return value must be a string object". However, does a
            # unicode object (being a subclass of basestring) count as a "string
            # object"?
            # If so, then return a unicode object:
            return unicode(obj)
            # Else encode it... but how? There are many choices... :)
            # Replace unprintables with escape codes?
            #return unicode(obj).encode(sys.getdefaultencoding(), 'backslashreplace_errors')
            # Replace unprintables with question marks?
            #return unicode(obj).encode(sys.getdefaultencoding(), 'replace')
            # ...

    # build list of single arg builtins, tolerant of Python version, that can be used as parse actions 
开发者ID:DavexPro,项目名称:PocHunter,代码行数:30,代码来源:pyparsing.py

示例4: pyparsing_parseresults_pformat

# 需要导入模块: import pprint [as 别名]
# 或者: from pprint import html [as 别名]
def pyparsing_parseresults_pformat(self, *args, **kwargs):
    """
    Pretty-print formatter for parsed results as a list, using the C{pprint} module.
    Accepts additional positional or keyword args as defined for the
    C{pprint.pformat} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pformat})
    """
    return pprint.pformat(self.asList(), *args, **kwargs) 
开发者ID:ip-tools,项目名称:patzilla,代码行数:9,代码来源:__init__.py

示例5: pprint

# 需要导入模块: import pprint [as 别名]
# 或者: from pprint import html [as 别名]
def pprint(self, *args, **kwargs):
        """
        Pretty-printer for parsed results as a list, using the
        `pprint <https://docs.python.org/3/library/pprint.html>`_ module.
        Accepts additional positional or keyword args as defined for
        `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .

        Example::

            ident = Word(alphas, alphanums)
            num = Word(nums)
            func = Forward()
            term = ident | num | Group('(' + func + ')')
            func <<= ident + Group(Optional(delimitedList(term)))
            result = func.parseString("fna a,b,(fnb c,d,200),100")
            result.pprint(width=40)

        prints::

            ['fna',
             ['a',
              'b',
              ['(', 'fnb', ['c', 'd', '200'], ')'],
              '100']]
        """
        pprint.pprint(self.asList(), *args, **kwargs)

    # add support for pickle protocol 
开发者ID:pyparsing,项目名称:pyparsing,代码行数:30,代码来源:results.py


注:本文中的pprint.html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。