利用pypinyin包
实现
import pypinyin
a = pypinyin.pinyin('你好世界', style=pypinyin.FIRST_LETTER)
b = []
for i in range(len(a)):
b.append(str(a[i][0]).upper())
c = ''.join(b)
print(c)
NHSJ
import pypinyin
a = pypinyin.pinyin('你好世界', style=pypinyin.FIRST_LETTER)
b = []
for i in range(len(a)):
b.append(str(a[i][0]).upper())
c = ''.join(b)
print(c)
NHSJ
转载于:https://www.cnblogs.com/qq_841161825/p/10162545.html