我在python中获得系统参数,并且在添加.lower()后传递它们有问题
我尝试过一些不同的解决方案,比如
list_join = ''.join(arg_list_split).lower()或
list_join = str(arg_list_split).lower()好像在我的程序电话里不认得一些大写字母,
如果我进行类似于python movie_find.py war =所有的调用,但是当我调用python movie_find.py war Spartacus =看起来它停止工作时,这意味着字符串参数没有正确地传递给post请求。
#!/usr/bin/env python3
import requests, re, sys
from bs4 import BeautifulSoup as bs
url = 'https://alltube.tv/szukaj'
arg_list_split = sys.argv[1:]
list_join = ' '.join(arg_list_split)
s = requests.Session()
response = s.post(url, data={'search' : list_join})
soup = bs(response.content, 'html.parser')
for link in soup.findAll('a', href=re.compile('serial')):
final_link = link['href']
if all(i in final_link for i in arg_list_split):
print(final_link)我想得到的结果,作为程序调用的小,或大写字母或字母,所有的降低和传递到适当的投递请求,然后从网站获得最后的链接。
发布于 2019-01-03 15:38:59
如果使用大写字符串调用脚本,则要比较表达式中的大写字符串和小写字符串。
if all(i in final_link for i in arg_list_split):这不会给你任何结果。
您需要确保arg_split_list只包含小写字符串,例如,执行
arg_list_split = [x.lower() for x in sys.argv[1:]]https://stackoverflow.com/questions/54024385
复制相似问题