python returns the first letter of Chinese characters

高洛峰
Release: 2016-10-18 10:11:56
Original
1635 people have browsed it

def get_first_letter(char):

   char=char.encode('GBK')

   

   if charb"xd7xf9":

       return ""

   if char

       return "a"

   if char

       return "b"

   if char

       return "c"

   if char

       return "d"

   if char

       return "e"

   if char

       return "f"

   if char

       return "g"

   if char

       return "h"

   if char

       return "j"

   if char

       return "k"

   if char

       return "l"

   if char

       return "m"

   if char

       return "n"

   if char

       return "o"

   if char

       return "p"

   if char

       return "q"

   if char

       return "r"

   if char

       return "s"

   if char

       return "t"

   if char

       return "w"

   if char

       return "x"

   if char

       return "y"

   if char

       return "z"


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!