问题描述
因此,我正在编写一个脚本,该脚本将基本上在google中搜索您所拥有的任何查询。
我唯一遇到的问题是在最后由os.system()
from os import system
q = input('what is your query:')
for char in '%':
q = q.replace(char,'%252B')
for char in '+':
q = q.replace(char,'%')
for char in ' ':
q = q.replace(char,'+')
我尝试将其全部不放入os.system()
中,而不是直接将其放入变量fq
fq = 'xdg-open https://www.google.com/search?q=',q,'&rlz=1C1CHBF_en-GBGB881GB881',sep=''
我已经去别处了,但是对我来说一切看起来都很复杂,因此,如果您能解释一下(不告诉我如何处理脚本),将不胜感激。
哦,我正在Windows上编写此代码,但打算在raspbian上使用,但据我所知这不会有所作为。
解决方法
您的系统调用应如下所示
system("xdg-open https:://www.google.com/search?q={}&rlz=1C1CHBF_en-GBGB881FB881".format(q))