emoji處理庫,emoji官網:https://pypi.org/project/emoji/python
#安裝 pip install emoji
官方例子以下:spa
清除命令:rest
emoji.demojize(str)
def filter_emoji(desstr,restr=''): #過濾表情 try: co = re.compile(u'[\U00010000-\U0010ffff]') except re.error: co = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]') return co.sub(restr, desstr)
打印全部的特殊字符:code
for i in range(0x0,0x10ffff): print(chr(i),end=" ") if i%16==15: print()
打印結果:blog