当前位置:   article > 正文

python数字转拼音输出_将数字拼音转换为带声调的拼音

\u01ba\u01b9\u0191\u01a8\u01d9\u01c8\u01d1\u01d7\u0191\u01a4\u01b3\u01b3\u0

我有一些python3代码可以做到这一点,它足够小,可以直接放在这里的答案中。在PinyinToneMark = {

0: "aoeiuv\u00fc",

1: "\u0101\u014d\u0113\u012b\u016b\u01d6\u01d6",

2: "\u00e1\u00f3\u00e9\u00ed\u00fa\u01d8\u01d8",

3: "\u01ce\u01d2\u011b\u01d0\u01d4\u01da\u01da",

4: "\u00e0\u00f2\u00e8\u00ec\u00f9\u01dc\u01dc",

}

def decode_pinyin(s):

s = s.lower()

r = ""

t = ""

for c in s:

if c >= 'a' and c <= 'z':

t += c

elif c == ':':

assert t[-1] == 'u'

t = t[:-1] + "\u00fc"

else:

if c >= '0' and c <= '5':

tone = int(c) % 5

if tone != 0:

m = re.search("[aoeiuv\u00fc]+", t)

if m is None:

t += c

elif len(m.gro

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/354944
推荐阅读
相关标签
  

闽ICP备14008679号