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

我有一些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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值