简体   繁体   English

如何打印 \0 \a \b \v \f 等字符

[英]How to print characters like \0 \a \b \v \f

In Python3在 Python3 中

>>> '\t'
'\t'

This is what I expect这是我所期望的

>>> '\0 \a \b \v \f'
'\x00 \x07 \x08 \x0b \x0c'

I don't want the hex values我不想要十六进制值

>>> '\\0 \\a \\b \\v \\f'
'\\0 \\a \\b \\v \\f'

This doesn't work either.这也不起作用。 How do I print these characters as shown '\0 \a \b \v\ f'?如何打印这些字符,如 '\0 \a \b \v\ f' 所示? I can print characters like \t, but cant print these for some reason.我可以打印 \t 之类的字符,但由于某种原因无法打印这些字符。

When you input your string in a function such as print, it works:当您在 function(例如 print)中输入字符串时,它可以工作:

>>> print('\\0 \\a \\b \\v \\f')
\0 \a \b \v \f

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 输出是像 [{a:b, d:c,....},{a:f, b:q,...},{a:v, b:k,....}, 的元组。 ..] - output is tuple like [{a:b, d:c,....},{a:f, b:q,...},{a:v, b:k,....},...] Python Jupyter Notebook:如何从Wikipedia十六进制值(如U + 1F0A1)打印Unicode字符? - Python Jupyter Notebook: How to print unicode characters from wikipedia hex value (like U+1F0A1)? 如何在python中打印characters等字符 - How can I print characters like ♟ in python 如何将“ \\ u5c0f \\ u738b \\ u5b50 \\ u003a \\ u6c49 \\ u6cd5 \\ u82f1 \\ u5bf9 \\ u7167”这样的字符串转换为汉字 - How can I convert strings like “\u5c0f\u738b\u5b50\u003a\u6c49\u6cd5\u82f1\u5bf9\u7167” to Chinese characters 在 python 中使用 b'' like f 字符串 - Using b'' like f string in python 如何为 function f 设置 `print(f)` 的 output - How to set the output of `print(f)` for a function f 如何在Python中将0x1b87打印为\\ x1b \\ x87? - How can I get 0x1b87 to print like \x1b\x87 in Python? 如何使用 f 字符串打印数学符号(使用乳胶),如 sigma? - How to print math symbols (using latex) like sigma with f-strings? 如何将带有特殊控制字符(例如\\'x1b')的字符串转换为标准字符串? - How to convert string with special control characters, like \'x1b', into a standard string? 如何在没有 b`` 字符串的情况下打印? - How to print without the b`` string?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM