当前位置:   article > 正文

Python3 将汉语转换为汉语拼音_python 句子 拼音 不带声调

python 句子 拼音 不带声调
import pypinyin
 
# 不带声调的(style=pypinyin.NORMAL)
def hp(word):
    s = ''
    for i in pypinyin.pinyin(word, style=pypinyin.NORMAL):
        s += ''.join(i)
    return s
 
# 带声调的(默认)
def hp2(word):
    s = ''
    for i in pypinyin.pinyin(word):
        s = s + ''.join(i) + " "
    return s
 
 
if __name__ == "__main__":
    print(hp("中国中央电视台春节联欢晚会"))
    print(hp2("中国中央电视台春节联欢晚会"))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
D:\Python\Python36\python.exe D:/pyWorkspace/reptile/chinesePYC.py
zhongguozhongyangdianshitaichunjielianhuanwanhui
zhōng guó zhōng yāng diàn shì tái chūn jié lián huān wǎn huì 
 
Process finished with exit code 0
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/354957?site
推荐阅读
相关标签
  

闽ICP备14008679号