在python脚本中运行curl命令不返回
我有如下curl命令,预期结果如下:在python脚本中运行curl命令不返回,python,python-2.7,Python,Python 2.7,我有如下curl命令,预期结果如下: [root@10 master]# curl -X GET -u 'admin:password' https://22.11.xx.1/api/1.0/reports/id/78/?csv_format=xls --insecure Output: {"file_url": "/var/www/graphics/images/temp/report365828.xlsx"} [root@10 master] 我有剧本: import su
[root@10 master]# curl -X GET -u 'admin:password' https://22.11.xx.1/api/1.0/reports/id/78/?csv_format=xls --insecure
Output:
{"file_url": "/var/www/graphics/images/temp/report365828.xlsx"}
[root@10 master]
我有剧本:
import subprocess
command = 'curl -X GET -u "admin:password" https://22.11.xx.1/api/1.0/reports/id/1/?csv_format=xls --insecure'
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
但是我在这里没有得到任何输出,我缺少什么吗
import os
command = """your command"""
result = os.popen(command).read()
print(result)
将其转换为命令列表
['curl',
'-X',
'GET',
'-u',
'"admin:password"',
'https://22.11.xx.1/api/1.0/reports/id/1/?csv_format=xls',
'--insecure']
如果您作为命令运行
echo hello
,是否会得到任何输出?我可能会在echo命令中得到重复的输出
['curl',
'-X',
'GET',
'-u',
'"admin:password"',
'https://22.11.xx.1/api/1.0/reports/id/1/?csv_format=xls',
'--insecure']