\v与\x0b或\x0c有何区别? [英] How does \v differ from \x0b or \x0c?

查看:2197
本文介绍了\v与\x0b或\x0c有何区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

键入 string.whitespace 为您提供一个字符串,其中包含由Python的字符串模块定义的所有空格字符:

 '\t\\\
\x0b\x0c\r'
/ pre>

\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's string 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 the string 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屋!

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