-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpinyin.py
37 lines (33 loc) · 873 Bytes
/
pinyin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from pypinyin import pinyin, lazy_pinyin, Style
# print (pinyin(u'蹒跚',style=Style.FINALS))
import sqlite3
# 兼容python2.7
# import sys
# reload(sys)
# sys.setdefaultencoding('utf-8')
#
def search(temp):
# search_temp = temp.decode('UTF-8')
search_pinyin = pinyin(temp,style=Style.FINALS)
# print search_pinyin
conn = sqlite3.connect('c.db')
c = conn.cursor()
i = 1
num = i*20
cursor = c.execute("SELECT * from lyc limit "+str(num)+","+str(num+20))
for row in cursor:
content = row[1]
lyc_name = row[6]
contents = content.split('|')
for item in contents:
item_temp = item[-2:]
pinyin_temp = pinyin(item,style=Style.FINALS)[-2:]
if(search_pinyin == pinyin_temp):
print (u'歌曲:'+lyc_name)
print (item)
print ('-----')
conn.close()
#
search('意义')