Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python3中的Curl命令_Python_Curl_Google Oauth - Fatal编程技术网

python3中的Curl命令

python3中的Curl命令,python,curl,google-oauth,Python,Curl,Google Oauth,我想用python执行curl with命令 通常,我只需要在终端中输入命令并按回车键 该命令显示如下: curl -H "`oauth2l header --json key.json mobileinsights`" https://mobileinsights.googleapis.com/v2/networks 结果是json格式。您可以加载操作系统和json加载模块,然后运行 os.executecurl URL将其存储在任何变量中,然后使用JSON加载模块将其转换为JSON格式使

我想用python执行curl with命令

通常,我只需要在终端中输入命令并按回车键

该命令显示如下:

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

结果是json格式。

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

使用该模块运行shell命令

import subprocess
result = subprocess.check_output('curl -H "`oauth2l header --json 
key.json mobileinsights`" https://mobileinsights.googleapis.com/v2/networks', shell=True)
然后,使用模块解析服务器返回的JSON数据

import json
result_json = json.loads(result) 

您的问题可能重复?您可以使用子流程从Python运行oauth2l header-json key.json mobileinsights。。。然后使用python中的任何HTTP库传递头