如何从 script.py 运行 httpie
how to run httpie from script.py
我需要从 py 脚本将表单发送到休息服务。我尝试使用 httpie 来做到这一点。
当我调用 run(['http', '--help'])
时,我得到了预期的结果。
如果我调用 run(['http', 'http://site/page'])
脚本被卡住,什么也没有发生。
我还尝试将 httpie 的 运行ning 放入 bash 脚本
#!/bin/bash
http http://site/page
结果与第一种情况相同。脚本卡住了。
我使用 ubuntu 16.04,所以我同时拥有 python2 和 python3。我 运行 我的脚本 python3。也许在这种情况下 p2 和 p3 之间存在冲突?
尝试包含 --ignore-stdin
选项:
run(['http', '--ignore-stdin', 'http://site/page'])
The --ignore-stdin
option prevents HTTPie from reading data from
stdin, which is usually not desirable during non-interactive
invocations.
我需要从 py 脚本将表单发送到休息服务。我尝试使用 httpie 来做到这一点。
当我调用 run(['http', '--help'])
时,我得到了预期的结果。
如果我调用 run(['http', 'http://site/page'])
脚本被卡住,什么也没有发生。
我还尝试将 httpie 的 运行ning 放入 bash 脚本
#!/bin/bash
http http://site/page
结果与第一种情况相同。脚本卡住了。
我使用 ubuntu 16.04,所以我同时拥有 python2 和 python3。我 运行 我的脚本 python3。也许在这种情况下 p2 和 p3 之间存在冲突?
尝试包含 --ignore-stdin
选项:
run(['http', '--ignore-stdin', 'http://site/page'])
The
--ignore-stdin
option prevents HTTPie from reading data from stdin, which is usually not desirable during non-interactive invocations.