willsonlincake 发表于 2022-4-5 21:54:52

Python str.isprintable()

检查字符是否是可打印输出的
# Python code for implementation of isprintable()

# checking for printable characters
string = 'My name is Ayush'
print(string.isprintable())

# checking if \n is a printable character
string = 'My name is \n Ayush'
print(string.isprintable())

# checking if space is a printable character
string = ''
print( string.isprintable())
结果
True
False
True
页: [1]
查看完整版本: Python str.isprintable()