我有一个文本文件' hi.txt'它有:
i have a friend whosr name is win.And has a friend who is great.
我有一个数据库表testtb
testid test1
1 hello
2 hi
3 friend
4 great
5 win
我想将输出打印为:
3朋友 5胜 4伟大我想使用全文索引打印所有行的相似单词。它不仅用于给定示例,所以不要单独限制此示例。请回答!
我创建了一个程序:
import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="mysql", # your password
db="sakila")
keyword = []
with open('qwer2.txt','r') as file, db as cursor:
for line in file:
if key in keywords:
print j#<-need to print the row that is matched
cursor.execute(query)