Check printable for Unicode
问题 I know that to check whether a string is printable, we can do something like: def isprintable(s,codec='utf8'): try: s.codec(codec) except UnicodeDecodeError: return False else: return True But is there a way to do it with Unicode, not a string? Btw, I'm working with tweets, and I convert the tweets to Unicode as follows text=unicode(status.text) 回答1: You are looking for a test for a range of codepoints, so you need a regular expression: import re # match characters from ¿ to the end of the