s=['\n', 'magnet:?xt=urn:btih:060C0CE5CFAE29A48102280B88943880689859FC\n']

上面是目标代码,一个列表,中间有\n,我们现在将其去掉

s=[x.strip() for x in magnet_link]

运行会发现结果为

s=['', 'magnet:?xt=urn:btih:060C0CE5CFAE29A48102280B88943880689859FC']

离我们的要求越来越近了

s=[x.strip() for x in magnet_link if x.strip()!='']

好了,结果出来了

s=['magnet:?xt=urn:btih:060C0CE5CFAE29A48102280B88943880689859FC']
04-15 05:09