擅长:python、mysql、java
<p>您可以尝试使用<code>unicodedata.category()</code>函数设置筛选器:</p>
<pre><code>import unicodedata
printable = {'Lu', 'Ll'}
def filter_non_printable(str):
return ''.join(c for c in str if unicodedata.category(c) in printable)
</code></pre>
<p>有关可用类别,请参见<a href="http://www.unicode.org/versions/Unicode9.0.0/ch04.pdf" rel="nofollow noreferrer">Unicode database character properties</a>中第175页的表4-9</p>