python3中的Curl命令

2024-09-30 03:23:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python执行curl with命令。在

通常,我只需要在终端输入命令,然后按回车键。在

命令显示如下:

curl -H "`oauth2l header --json key.json mobileinsights`"  https://mobileinsights.googleapis.com/v2/networks

结果是json格式的。在


Tags: keyhttps命令comjson终端withcurl
2条回答

使用^{}模块运行shell命令。在

import subprocess
result = subprocess.check_output('curl -H "`oauth2l header  json 
key.json mobileinsights`" https://mobileinsights.googleapis.com/v2/networks', shell=True)

然后,使用^{}模块解析服务器返回的JSON数据。在

^{pr2}$

您可以加载OS和JSON加载模块,然后运行 操作系统执行(curl URL)将其存储在任何变量中,然后使用JSON加载模块将其转换为JSON格式

相关问题 更多 >

    热门问题