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