【发布时间】:2019-02-28 11:55:06
【问题描述】:
这里的目标是从网站获取密钥或密码。
在 Python 中,我尝试了 os.system() 和 subprocess.call([]) 来运行以下 linux 命令,但两种方法都以错误告终。
os.system("curl -s http://example.com | grep ' "Key" : * ' | cut -f1 -d " " | cut -b5- | rev | cut -b9- | rev")
在 linux 中正在使用以下,并且工作正常。
PW = 'curl -s http://example.com | grep ' "Key" : * ' | cut -f1 -d " " | cut -b5- | rev | cut -b8- | rev'
我看到的错误是 SyntaxError: invalid syntax,它指向“关键”部分
【问题讨论】:
标签: linux python-3.x subprocess os.system