zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【说站】python中isprintable判断字符的使用

Python字符 使用 判断
2023-06-13 09:13:17 时间

python中isprintable判断字符的使用

说明

1、判断字符是否为可打印字符。isprintable()用于判断字符串中的所有字符是否为空。

Unicode字符集中在Other和Separator类别中的字符是不可打印的字符(但不包括ASCII码中的空格(0x20)。

2、isprintable()可以用来判断转义字符。

实例

str1 = '\n\t'
print(str1.isprintable())  # False
str1 = 'mr_soft'
print(str1.isprintable())  # True
str1 = '12345'
print(str1.isprintable())  # True
str1 = '蜘蛛侠'
print(str1.isprintable())  # True

以上就是python中isprintable判断字符的使用,希望对大家有所帮助。更多Python学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。