【发布时间】:2014-02-02 06:02:41
【问题描述】:
我有以下 json 格式的配置文件:
{"end_point":"http://domain.com","auth_token":"e91a0ffe758c194f2326eb4daed0","widgets":{"host_info":"fd8a63a33d1d15521e3499289a312","memory_info":"0bc2c3345ba7b129f3328bc4c507ad","cpu_info":"5a2b41cd21d56773250dc41dbd73681"}}
我正在尝试使用子进程发送数据。问题是如何从 json 文件中获取数据:
#Send using subprocess
import subprocess
subprocess.call([
'curl',
'-X',
'POST',
'-H',
'Content-Type: application/json',
'-d',
'{ "auth_token": "GETFROMCONFIGFILE(authtoken)", "widget": "GETFROMCONFIGFILE(widgets)", "title": "Something", "items":[{"label": "TEST", "value": "11"}, {"label": "1", "value": "11"}] }',
'GETFROMFILE(endpoint)'
提前谢谢你。
【问题讨论】:
标签: python curl subprocess