判断一个字符是否是组合变音符号

ʞɔı*_*ɔıu 3 python unicode diacritics

如果你在python(2.x)中循环使用unicode字符串,请说:

ak.sɛp.tɑ

你怎么知道当前的char是否是一个组合变音符号?

例如,上面字符串中的最后一个字符实际上是一个组合标记:

ak.sɛp.tɑ - >

Joe*_*erg 8

使用unicodedata模块:

import unicodedata
if unicodedata.combining(u'a'):
    print "is combining character"
else:
    print "is not combining"
Run Code Online (Sandbox Code Playgroud)

这些帖子也很重要

如何使用Python反转Unicode分解?

删除Python unicode字符串中重音的最佳方法是什么?