标签:python set search 判断 you ref sprint str ons
方法一: 正则
>>> import re
>>> # Printable
>>> print re.search(r‘[^\x20-\x7e]‘, ‘test‘)
None
>>> # Unprintable
>>> re.search(r‘[^\x20-\x7e]‘, ‘test\x00‘) != None
True
方法二:
import string
printset = set(string.printable)
isprintable = set(yourstring).issubset(printset)
原文详见:
Python 判断字符串书否是纯ASCII (printable)
标签:python set search 判断 you ref sprint str ons
原文地址:https://www.cnblogs.com/yunqimg/p/ascii-printable.html