xpinyin提供把汉字转为汉语拼音的功能。安装此模块pip install xpinyin简单用例:from xpinyin import Pinyin pin = Pinyin() test1 = pin.get_pinyin("大河向东流") #默认分割符为- print(test1) test2 = pin.get_pinyin("大河向东流", "") print(test2)