\v与\x0b或\x0c有何区别? [英] How does \v differ from \x0b or \x0c?
问题描述
键入 string.whitespace
为您提供一个字符串,其中包含由Python的字符串
模块定义的所有空格字符:
'\t\\\
/ pre>
\x0b\x0c\r'
\x0b
和\x0c
似乎给了一个垂直标签。>>>打印'first\x0bsecond'
first
second
\v
给出相同的效果。这三种不同呢?为什么字符串
模块使用\x0b
或\x0c
通过简单的\v
?解决方案
\v
是\x0b
:>>> '\v'
'\x0b'
但Python中的字符串文字表示正在使用
\x0b
符号。
Python字符串文字表示法仅使用
\\\
,
\r
和\t
,其他一切不能使用\xhh
表示法来表示不可打印的ASCII字符。
\\ x0c
是一个 表单Feed ;它迫使打印机移动到下一张纸。您还可以在Python中将其表达为\f
:> ;>> '\f'
'\x0c'
在终端中,
\v
和\f
通常是一样的。Typing
string.whitespace
gives you a string containing all whitespace characters defined by Python'sstring
module:'\t\n\x0b\x0c\r '
Both
\x0b
and\x0c
seem to give a vertical tab.>>> print 'first\x0bsecond' first second
\v
gives the same effect. How are these three different? Why does thestring
module use\x0b
or\x0c
over the simpler\v
?解决方案
\v
is\x0b
:>>> '\v' '\x0b'
but the string literal representation in Python is using the
\x0b
notation instead.The Python string literal representation only ever uses
\n
,\r
and\t
, everything else that is not a printable ASCII character is represented using the\xhh
notation instead.
\x0c
is a form feed; it forces a printer to move to the next sheet of paper. You can also express it as\f
in Python:>>> '\f' '\x0c'
In terminals the effects of
\v
and\f
are often the same.这篇关于\v与\x0b或\x0c有何区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!