方法一: 正则
>>> import re
>>> # Printable
>>> print re.search(r'[^x20-x7e]', 'test')
None
>>> # Unprintable
>>> re.search(r'[^x20-x7e]', 'testx00') != None
True
方法二:
import string
printset = set(string.printable)
isprintable = set(yourstring).issubset(printset)
原文详见: