下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#!/usr/bin/env python

# -*- coding: utf-8 -*-

def multi_get_letter(str_input):

if isinstance(str_input,unicode):

unicode_str = str_input

else:

try:

unicode_str = str_input.decode('utf8')

except:

try:

unicode_str = str_input.decode('gbk')

except:

print 'unknown coding'

return

return_list = []

for one_unicode in unicode_str:

return_list.append(single_get_first(one_unicode))

return return_list

def single_get_first(unicode1):

str1 = unicode1.encode('gbk')

try:

ord(str1)

return str1

except:

asc = ord(str1[0]) * 256 + ord(str1[1]) - 65536

if asc >= -20319 and asc <= -20284:

return 'a'

if asc >= -20283 and asc <= -19776:

return 'b'

if asc >= -19775 and asc <= -19219:

return 'c'

if asc >= -19218 and asc <= -18711:

return 'd'

if asc >= -18710 and asc <= -18527:

return 'e'

if asc >= -18526 and asc <= -18240:

return 'f'

if asc >= -18239 and asc <= -17923:

return 'g'

if asc >= -17922 and asc <= -17418:

return 'h'

if asc >= -17417 and asc <= -16475:

return 'j'

if asc >= -16474 and asc <= -16213:

return 'k'

if asc >= -16212 and asc <= -15641:

return 'l'

if asc >= -15640 and asc <= -15166:

return 'm'

if asc >= -15165 and asc <= -14923:

return 'n'

if asc >= -14922 and asc <= -14915:

return 'o'

if asc >= -14914 and asc <= -14631:

return 'p'

if asc >= -14630 and asc <= -14150:

return 'q'

if asc >= -14149 and asc <= -14091:

return 'r'

if asc >= -14090 and asc <= -13119:

return 's'

if asc >= -13118 and asc <= -12839:

return 't'

if asc >= -12838 and asc <= -12557:

return 'w'

if asc >= -12556 and asc <= -11848:

return 'x'

if asc >= -11847 and asc <= -11056:

return 'y'

if asc >= -11055 and asc <= -10247:

return 'z'

return ''

def main(str_input):

a = multi_get_letter(str_input)

b = ''

for i in a:

b= b+i

print b

if __name__ == "__main__":

str_input=u'欢迎你'

main(str_input)

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

python汉字拼音查询_python获取一组汉字的拼音首字母相关推荐

  1. python汉字拼音查询_python获取一组汉字拼音首字母的方法

    本文实例讲述了python获取一组汉字拼音首字母的方法.分享给大家供大家参考.具体实现方法如下: #!/usr/bin/env python # -*- coding: utf-8 -*- def m ...

  2. python汉字转拼音首字母_python获取一组汉字拼音首字母的方法

    作者:不吃皮蛋 字体: 类型:转载 这篇文章主要介绍了python获取一组汉字拼音首字母的方法,涉及Python针对汉字操作的相关技巧,需要的朋友可以参考下 本文实例讲述了python获取一组汉字拼音 ...

  3. python怎么识别拼音-python获取一组汉字拼音首字母的方法

    本文实例讲述了python获取一组汉字拼音首字母的方法.分享给大家供大家参考.具体实现方法如下: #!/usr/bin/env python # -*- coding: utf-8 -*- def m ...

  4. python咋变汉语_python实现将汉字转换成汉语拼音的库

    本文实例讲述了python实现将汉字转换成汉语拼音的库.分享给大家供大家参考.具体分析如下: 下面的这个python库可以很容易的将汉字转换成拼音,其中用到了一个word.data 的字典,可点击此处 ...

  5. 中文汉字转拼音——大写(默认),小写,首字母大写

    ...好吧先上效果图~ 主要代码: public class MainActivity extends Activity {private TextView tv_test;String str = ...

  6. python实现火车票查询_Python脚本实现12306火车票查询系统

    最近我看到看到使用python实现火车票查询,我自己也实现了,感觉收获蛮多的,下面我就把每一步骤都详细给分享出来.(注意使用的是python3) 首先我将最终结果给展示出来: 在cmd命令行执行:py ...

  7. python数据库模糊查询_Python操作mongodb数据库进行模糊查询操作示例

    本文实例讲述了Python操作mongodb数据库进行模糊查询操作.分享给大家供大家参考,具体如下: # -*- coding: utf-8 -*- import pymongo import re ...

  8. python提取矩阵元素_python获取array中指定元素的示例

    python获取array中指定元素的示例 对于array,如2-D的array,如何取指定元素 设array为3*10的shape s = array([[ 0, 1, 2, 3, 4, 5, 6, ...

  9. mysql 拼音首字母_MySQL 获取某个字段的汉语拼音首字母 - 文章

    在做一个商城的时候,需要用户能有切换城市的功能,城市列表按照汉语拼音首字母排序,城市的数据是从国家统计局扒下来的,只有城市的编码和城市的名称,通过下面的 MySQL 函数,获取某个汉语的首字母. CR ...

最新文章

  1. 基于脑电和特征加权阶段训练的驾驶员疲劳状态估计
  2. Sigmoid 函数(To be continued)
  3. XML Schema简介
  4. 文件查找-locate find 学习笔记
  5. oracle 加密怎么解密,oracle加密encrypt,解密decrypt,
  6. javamail腾讯企业邮箱发送邮件
  7. dj鲜生-31-用户中心-功能需求分析
  8. React的组件模式 1
  9. java项目命令编译,打包,运行
  10. java解析xml文件
  11. CSS3 Transform 变形
  12. 斯坦福大学的 CS231n课程
  13. 计算机一级office操作题题库百度云,不容错过!计算机等级考试题库之一级MS Office操作题与答案...
  14. MacOS下AndroidStudio无法启动
  15. 台式计算机怎么安装无线网卡,台式机用无线网卡,小编教你台式机怎么用无线网卡...
  16. 扒开系统调用的三层皮(上)
  17. HBase 记忆内容(简答题)
  18. codeforces1670F Jee, You See?(DP/位运算/前缀和/组合数)
  19. 苹果手机有4g信号但是微信未连接服务器,苹果5s有显示4g网络但无上微信 是不是那里设置了 今天才出现的...
  20. 数组排序(5) 快速排序之三指针分区法

热门文章

  1. PCM音频文件格式的头信息
  2. 基础的网络服务器开发
  3. 如何配置NATAPP
  4. 开源飞控初探(三)两大开源飞控的历史
  5. 其他|Cherry 键盘 Fn 锁定切换方法
  6. 网络基础---广域网技术
  7. 搜狗输入法如何输入直角引号(「『』」 )
  8. 使用MSF进行提权(windows提权、linux提权、wesng使用)
  9. win10修改桌面图标大小
  10. hin2vec 异质信息网络表示学习 个人笔记