Python 将汉字转为拼音
https://blog.csdn.net/weixin_42464956/article/details/110927073
##pip install xpinyin -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
from xpinyin import Pinyin
import os
def is_Chinese(ch):
return True if '\u4e00' <= ch <= '\u9fff' else False
p = Pinyin()
dirs=os.getcwd()
for f in os.listdir(dirs):
if os.path.isdir(os.path.join(dirs, f)) and is_Chinese(f[0]):
res = p.get_pinyin(f)
res=res.replace('-', '')
print(res)
浙公网安备 33010602011771号