tokenize 模块中的 Python 2 换行符 [英] Python 2 newline tokens in tokenize module

查看:35
本文介绍了tokenize 模块中的 Python 2 换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python 中使用 tokenize 模块,想知道为什么有 2 个不同的换行符:

I am using the tokenize module in Python and wonder why there are 2 different newline tokens:

NEWLINE = 4
NL = 54

将不胜感激任何可以生成两个令牌的代码示例.

Any examples of code that would produce both tokens would be appreciated.

推荐答案

根据python文档:

According to python documentation:

tokenize.NL
用于指示非终止换行符的令牌值.新线token 表示 Python 代码逻辑行的结束;NL代币当一个逻辑代码行连续多个时生成物理线路.

tokenize.NL
Token value used to indicate a non-terminating newline. The NEWLINE token indicates the end of a logical line of Python code; NL tokens are generated when a logical line of code is continued over multiple physical lines.

更多信息:https://docs.python.org/2/library/tokenize.html

这篇关于tokenize 模块中的 Python 2 换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆