一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - python獲取一組漢字拼音首字母的方法

python獲取一組漢字拼音首字母的方法

2020-07-19 10:29不吃皮蛋 Python

這篇文章主要介紹了python獲取一組漢字拼音首字母的方法,涉及Python針對漢字操作的相關技巧,需要的朋友可以參考下

本文實例講述了python獲取一組漢字拼音首字母的方法。分享給大家供大家參考。具體實現方法如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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)

希望本文所述對大家的Python程序設計有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 四虎4hu永久免费 | 人与动videos | 桃子视频www | 人人艹在线视频 | 美女牲交毛片一级视频 | 99精品国产高清一区二区三区香蕉 | 俺去也亚洲色图 | 精品小视频在线 | 91香蕉国产在线观看人员 | 二区免费视频 | tk白丝丨vk | 被教官揉了一晚上的奶小说 | 国产精品日韩在线观看 | 亚洲国产成人久久99精品 | 美女张开腿黄网站免费精品动漫 | 情侣奴伺候女王第2部分小说 | 亚洲天堂在线视频观看 | 国产精彩对白综合视频 | 国产精品午夜剧场 | 欧美日韩精品一区二区三区高清视频 | 欧美摘花破处 | 久久视频在线视频 | av91在线| 国产一级在线观看 | 香蕉视频在线观看网址 | 女烈受刑重口小说 | 久久久久琪琪精品色 | 69午夜影院 | 无人区在线观看免费完整版免费 | 女人张开腿让男人桶视频免费大全 | 91香蕉小视频 | 深夜日韩 | 蘑菇香蕉茄子绿巨人丝瓜草莓 | 欧美日韩亚洲高清不卡一区二区三区 | 成人免费网址 | 国产成人精品视频午夜 | 无人区免费一二三四乱码 | 国产精品福利短视在线播放频 | 女人是男人的未来1分49分 | porno movie hd高清 | 亚洲AV综合99一二三四区 |