1 import pypinyin
2
3 word_list = [ '+有趣', '+期待', '+着迷', '乐观','惊喜', '欣赏', '浪漫', '淡定', '渴望',]
4
5
6 def hanzi2pinyin(word):
7 '''把输入的关键词转换为拼音'''
8 s = ''
9 for i in pypinyin.pinyin(word, style=pypinyin.NORMAL):
10 s += ''.join(i)
11 return s
12
13
14 def pinyin_word():
15 '''组合成拼音词列表'''
16 pinyin_list = []
17 for i in word_list:
18 if i.startswith('+'):
19 i = i.replace('+', '')
20 res = hanzi2pinyin(i)
21 res = hanzi2pinyin(i)
22 pinyin_list.append(res)
23 return pinyin_list
24
25 new_word = pinyin_word()
26 for i in new_word:
27 print(i)