加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python返回汉字首字母示例

发布时间:2020-05-24 21:02:15 所属栏目:Python 来源:互联网
导读: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"

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读