python返回汉字的首字母
发布时间:2020-05-25 00:21:53 所属栏目:Python 来源:互联网
导读:python返回汉字的首字母
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 def get_first_letter(char):
char=char.encode('GBK')
if char<b"xb0xa1" or char>b"xd7xf9":
return ""
if char<b"xb0xc4":
return "a"
if char<b"xb2xc0":
return "b"
if char<b"xb4xed":
return "c"
if char<b"xb6xe9":
return "d"
if char<b"xb7xa1":
return "e"
if char<b"xb8xc0":
return "f"
if char<b"xb9xfd":
return "g"
if char<b"xbbxf6":
return "h"
if char<b"xbfxa5":
return "j"
if char<b"xc0xab":
return "k"
if char<b"xc2xe7":
return "l"
if char<b"xc4xc2":
return "m"
if char<b"xc5xb5":
return "n"
if char<b"xc5xbd":
return "o"
if char<b"xc6xd9":
return "p"
if char<b"xc8xba":
return "q"
if char<b"xc8xf5":
return "r"
if char<b"xcbxf9":
return "s"
if char<b"xcdxd9":
return "t"
if char<b"xcexf3":
return "w"
if char<b"xd1x88":
return "x"
if char<b"xd4xd0":
return "y"
if char<b"xd7xf9":
return "z"
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
