我想从MySQL数据库中选择一些行并保存在一个列表中,然后与变量值进行比较,但是结果是空的
这是我的密码:
mycursor = lucas_db.cursor()
mycursor.execute("SELECT Release_Name FROM Lucas_Table WHERE Published_Time > SUBDATE( CURRENT_TIME, INTERVAL 30 MINUTE)")
myresult = mycursor.fetchall()
print(myresult)
last=input('give me:')
me = difflib.get_close_matches(last, myresult)
print(me)
结果是:
[('Food-Fact or Fiction S04E16 Tea Time WEBRip x264-CAFFEiNE',), ('A Million Little Things S01E17 720p HEVC x265-MeGusta',), ('The Pioneer Woman S21E09 16-Minute Chicken 480p x264-mSD',), ('The Pioneer Woman S21E09 16-Minute Chicken AAC MP4-Mobile',), ('Northern Rescue S01E09 720p HEVC x265-MeGusta',), ('Food-Fact or Fiction S04E16 Tea Time XviD-AFG',), ('Food-Fact or Fiction S04E16 Tea Time 480p x264-mSD',), ('Food-Fact or Fiction S04E16 Tea Time AAC MP4-Mobile',), ('How to Get Away with Murder S05E15 720p HEVC x265-MeGusta',), ('The Titan Games S01E09 720p HEVC x265-MeGusta',)]
give me:The Pioneer Woman S21E09 16-Minute Chicken 480p x264-mSD
[]
***Repl Closed***
可以使用
chain.from_iterable()
链接myresult
中的所有字符串。您还可以尝试更改difflib.get_close_matches()
中的cutoff
参数:输出:
多亏了@Rich Andrews,它成功了:
“詹姆斯·马丁斯伟大的英国冒险S01E03 WEB x264 LiGATE”的结果是:
myresult将是一个元组列表,其中一个元素是数据库中的单个select列。你知道吗
下面说明了difflib的情况。你知道吗
相关问题 更多 >
编程相关推荐