def ositien(zi): unicode = str(zi.encode('unicode_escape')[2:]) vowel = [] consonant = [] ost = "" for i in unicode: if i in "0123456789": vowel.append(dictionary[i]) if i in "abcdefghijklmnopqrst": consonant.append(dictionary[i]) del consonant[0] if len(vowel) == 0: ost = consonant[0] + "a" elif len(consonant) == 0: ost = vowel[0] else: for i in range(min(len(vowel),len(consonant))): ost = ost + consonant[i] + vowel[i] return ost dictionary = {'0':'a','1':'i','2':'u','3':'e','4':'o','5':'a','6':'i','7':'u','8':'e','9':'o','a':'k','b':'s','c':'t','d':'n','e':'h','f':'m','g':'y','h':'r','i':'w','j':'g','k':'z','l':'d','m':'b','n':'p','o':'k','p':'s','q':'t','r':'n','s':'h','t':'m','u':'y','v':'r','w':'w','x':'g','y':'z','z':'d'} chinese = input("输入中文(注意将词用空格分开,不要加标点):") word = "" ost_word = "" sentence = "" for i in range(len(chinese)): word += chinese[i] if chinese[i] == ' ' or i == len(chinese)-1: for j in word.rstrip(): ost_word += ositien(j) sentence = sentence + ost_word + ' ' word = "" ost_word = "" sentence = sentence.rstrip() + '.' print(sentence.capitalize())