當前位置: 首頁>>代碼示例>>Python>>正文


Python lexers.Python3Lexer方法代碼示例

本文整理匯總了Python中pygments.lexers.Python3Lexer方法的典型用法代碼示例。如果您正苦於以下問題:Python lexers.Python3Lexer方法的具體用法?Python lexers.Python3Lexer怎麽用?Python lexers.Python3Lexer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pygments.lexers的用法示例。


在下文中一共展示了lexers.Python3Lexer方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: printargs

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def printargs():
    """Prints out all command-line parameters."""
    switch = {BGColor.LIGHT: 'xcode',
              BGColor.DARK: 'vim',
              BGColor.UNKNOWN: 'default'}
    style = switch[terminal_bg()]
    pprint = print
    try:
        import pygments
        from pygments.lexers import Python3Lexer
        from pygments.formatters import Terminal256Formatter
        pprint = partial(pygments.highlight, lexer=Python3Lexer(),
                         formatter=Terminal256Formatter(style=style),
                         outfile=sys.stdout)
    except ImportError:
        pass
    print('Parameters:')
    for key in sorted(ARGS):
        v = repr(getattr(ARGS, key))
        print('% 16s: ' % key, end='')
        pprint(v)
    print() 
開發者ID:crowsonkb,項目名稱:style_transfer,代碼行數:24,代碼來源:style_transfer.py

示例2: __init__

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def __init__(self, data):
        # Logger
        self.logger = Log()
        # Max ID
        self.max_id = 10 * 10 * 10
        # Get tokens
        self.logger.log('Getting tokens from file...')
        self._tokens = list(Python3Lexer().get_tokens(data))
        # Tokenize
        self._tokenize()

    # Get token by id 
開發者ID:PyObfx,項目名稱:PyObfx,代碼行數:14,代碼來源:tokenizer.py

示例3: __init__

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def __init__(self, parent, lexer=None):
        super(PygmentsHighlighter, self).__init__(parent)

        self._document = self.document()
        self._formatter = HtmlFormatter(nowrap=True)
        self.set_style('default')
        if lexer is not None:
            self._lexer = lexer
        else:
            if PY3:
                self._lexer = Python3Lexer()
            else:
                self._lexer = PythonLexer() 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:15,代碼來源:pygments_highlighter.py

示例4: lexer3

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def lexer3():
    yield Python3Lexer() 
開發者ID:pygments,項目名稱:pygments,代碼行數:4,代碼來源:test_python.py

示例5: test_others_work

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def test_others_work():
    """Check other formatters don't crash."""
    highlight(CODE, Python3Lexer(), LatexFormatter(style=MyStyle))
    highlight(CODE, Python3Lexer(), HtmlFormatter(style=MyStyle)) 
開發者ID:pygments,項目名稱:pygments,代碼行數:6,代碼來源:test_terminal_formatter.py

示例6: test_256esc_seq

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def test_256esc_seq():
    """
    Test that a few escape sequences are actually used when using ansi<> color
    codes.
    """
    def termtest(x):
        return highlight(x, Python3Lexer(),
                         Terminal256Formatter(style=MyStyle))

    assert '32;101' in termtest('0x123')
    assert '92;42' in termtest('123')
    assert '90' in termtest('#comment')
    assert '94;41' in termtest('"String"') 
開發者ID:pygments,項目名稱:pygments,代碼行數:15,代碼來源:test_terminal_formatter.py

示例7: render

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import Python3Lexer [as 別名]
def render(self, *args, **kwargs):
        from pygments import highlight
        from pygments.lexers import Python3Lexer
        from pygments.formatters import HtmlFormatter
        code = render_output(self.item, self.pprint.pformat)
        formatter = HtmlFormatter(noclasses=True)
        formatter.style.background_color = 'transparent'
        return _format_output(highlight(code, Python3Lexer(), formatter)) 
開發者ID:vinci1it2000,項目名稱:schedula,代碼行數:10,代碼來源:__init__.py


注:本文中的pygments.lexers.Python3Lexer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。