Python 获取中文的首字母 和 全部拼音首字母

 

代码如下:

import pinyin

def getStrAllAplha(str):
    return pinyin.get_initial(str, delimiter="").upper()
    
def getStrFirstAplha(str):
    str=getStrAllAplha(str)
    str=str[0:1]
    return str.upper()
str = '你好在哪来'

print(getStrAllAplha(str))
print(getStrFirstAplha(str))

输出:

NHZNL

N

本文原文地址:https://www.cnblogs.com/wukong1688/p/11149049.html

 

输出:

NHZNL

N

本文原文地址:https://www.cnblogs.com/wukong1688/p/11149049.html

 

相关文章:

  • 2022-12-23
  • 2021-06-13
  • 2022-01-15
  • 2021-07-30
  • 2021-05-18
  • 2022-12-23
  • 2021-06-06
  • 2021-05-18
猜你喜欢
  • 2021-06-10
  • 2021-11-18
  • 2022-02-13
  • 2022-02-09
相关资源
相似解决方案