如何在 Python 中将换行符 '\n' 之类的空格打印到屏幕上?
how to print whitespaces like newline character '\n' to the screen in Python?
我使用 Mac 和 python2,我想检查哪些字符被我的操作系统视为空格。
在IDLE中,它returns'\t\n\x0b\x0c\r',很好。
但我使用 pycharm 编辑器,当我使用以下代码时:
import string
print string.whitespace
然后我得到的不是空白字符“\t\n\x0b\x0c\r”,而是一个制表符、一个换行符等。字符打印。
我怎样才能得到字符串形式的结果而不是这些空格的实际操作?
不确定我是否理解正确。你想看到这样的表示吗:
import string
print repr(string.whitespace)
我使用 Mac 和 python2,我想检查哪些字符被我的操作系统视为空格。
在IDLE中,它returns'\t\n\x0b\x0c\r',很好。
但我使用 pycharm 编辑器,当我使用以下代码时:
import string
print string.whitespace
然后我得到的不是空白字符“\t\n\x0b\x0c\r”,而是一个制表符、一个换行符等。字符打印。
我怎样才能得到字符串形式的结果而不是这些空格的实际操作?
不确定我是否理解正确。你想看到这样的表示吗:
import string
print repr(string.whitespace)