Python 字符串 isprintable() 方法

實例

檢查文本中的所有字符是否可打印:

txt = "Hello! Are you #1?"
x = txt.isprintable()
print(x)

運行實例

定義和用法

如果所有字符都是可打印的,則 isprintable() 方法返回 True,否則返回 False。

不可打印的字符可以是回車和換行符。

語法

string.isprintable()

參數值

無參數.

更多實例

實例

檢查文本中的所有字符是否可打印:

txt = "Hello!\nAre you #1?"
x = txt.isprintable()
print(x)

運行實例