[Python] Python 获取中文的首字母 和 全部拼音首字母
Python 获取中文的首字母 和 全部拼音首字母
代码如下:
import pinyin def getStrAllAplha(str):
return pinyin.get_initial(str, delimiter="").upper() def getStrFirstAplha(str):
str=getStrAllAplha(str)
str=str[:]
return str.upper() str = '你好在哪来' print(getStrAllAplha(str))
print(getStrFirstAplha(str))
输出:
NHZNL
N
本博客地址: wukong1688
本文原文地址:https://www.cnblogs.com/wukong1688/p/11149049.html
转载请著名出处!谢谢~~
[Python] Python 获取中文的首字母 和 全部拼音首字母的更多相关文章
- python 获取中文拼音首字母;判断文件夹是否存在
1.如何获取中文字符串的首字母 import pinyin #输入name def get_pinyin_first_alpha(name): return "".join([i[ ...
- php 获取中文字符拼音首字母
//php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){return '';} $fchar=ord($str{}); }); ...
- sqlservice 查询该字段的值是否为数字、不包含a-z字母、获取中文的首字母
select zjm from xskh where guid_yw='e6ee44f3-98ab-4446-bd9b-db2e525d3b24' and zjm not like '%[ABCDE ...
- JS获取中文拼音首字母,并通过拼音首字母高速查找页面内的中文内容
实现效果: 图一: 图二: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdGVzdGNzX2Ru/font/5a6L5L2T/fontsize/400/f ...
- php获取中文字符拼音首字母
//php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){ return ''; } $fchar = ord($str{0}) ...
- PHP获取中文首字母的函数
PHP获取中文首字母的函数 <?php header("Content-type: text/html; charset=utf-8"); function getFirst ...
- 【转】【Python】 python中的编码问题报错 'ascii' codec can't decode 及 URL地址获取中文
1.unicode.gbk.gb2312.utf-8的关系 http://www.pythonclub.org/python-basic/encode-detail 这篇文章写的比较好,utf-8是u ...
- 获取中文的首字母demo
import net.sourceforge.pinyin4j.PinyinHelper; /** * * @Title: getPinYinHeadChar * @Description: TODO ...
- Java获取中文拼音、中文首字母缩写和中文首字母
获取中文拼音(如:广东省 -->guangdongsheng) /** * 得到中文全拼 * @param src 需要转化的中文字符串 * @return */ public static S ...
随机推荐
- 分库分表数据库自增 id
分库分表之后,ID 主键如何处理? 面试题 分库分表之后,id 主键如何处理? 面试官心理分析 其实这是分库分表之后你必然要面对的一个问题,就是 id 咋生成?因为要是分成多个表之后,每个表都是从 1 ...
- Centos 7.6搭建Skywalking6.5+es6.2.4
软件包版本1.elasticsearch-6.2.4.tar.gz,下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elastics ...
- Mysql select into outfile 命令
[1]Mysql select into outfile命令 在Mysql中,与load data infile命令作用相反的一个命令是select into outfile命令 select int ...
- Mysql 错误:Duplicate entry '0' for key 'PRIMARY'
[1]添加数据报错:Duplicate entry '0' for key 'PRIMARY' (1)问题现象 SQL 语句如下: DROP TABLE test_distinct; CREATE T ...
- @Bean修饰的方法参数的注入方式
@Bean修饰的方法参数的注入方式: 方法参数默认注入方式为Autowired,即先根据类型匹配,若有多个在根据名称进行匹配. 1:复杂类型可以通过@Qualifier(value=“XXX”)限定; ...
- centos7安装pyenv
一.安装pyenv: 1.>安装依赖包: yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel ...
- RecyclerView预览数据
我们在布局文件里定义RecyclerView时,可以使用tools属性预览数据,如下: <android.support.v7.widget.RecyclerView android:layou ...
- Password file not found:.../jmxremote.password
jmxremote.password 在jdk/jre/lib/management/下,jmxremote.password.template复制,去掉.template后缀 在配置JMX远程访问的 ...
- 【02】Saltstack:Grains and Pillar
写在前面的话 上一节谈及了 Saltstack 的安装和初始化配置,本节将谈谈 Saltstack 中两个重要的东西,Grains 和 Pillar. 数据系统 Grains 入门 Grains 是静 ...
- 2019-11-29-win10-uwp-手把手教你使用-asp-dotnet-core-做-cs-程序
原文:2019-11-29-win10-uwp-手把手教你使用-asp-dotnet-core-做-cs-程序 title author date CreateTime categories win1 ...