Home  >  Article  >  Backend Development  >  python returns the first letter of Chinese characters

python returns the first letter of Chinese characters

高洛峰
高洛峰Original
2016-10-18 10:11:561627browse

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"


Statement:
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