Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.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
Python Tkinter从curl命令返回0_Python_Python 2.7 - Fatal编程技术网

Python Tkinter从curl命令返回0

Python Tkinter从curl命令返回0,python,python-2.7,Python,Python 2.7,我正在尝试使用以下命令通过curl访问URL: curl -s http://path.to.url.com/ 预期的结果大致是这样的 '{"ResponseCode":"SUCCESS","information":"info"}' 我试图让tkinter框显示curl命令的结果,但它只输出0 通常使用python,我看到的是无问题的定期返回。我的脚本看起来像这样(一些数据经过编辑) 上述操作将在tkinter窗口中创建一个只返回0的框,看起来您都是正确的。将结果更改为子流程。检查输出(

我正在尝试使用以下命令通过curl访问URL:

curl -s http://path.to.url.com/ 
预期的结果大致是这样的

'{"ResponseCode":"SUCCESS","information":"info"}'
我试图让tkinter框显示curl命令的结果,但它只输出0

通常使用python,我看到的是无问题的定期返回。我的脚本看起来像这样(一些数据经过编辑)


上述操作将在tkinter窗口中创建一个只返回0的框,看起来您都是正确的。将结果更改为
子流程。检查输出(“curl-shttp://path.to.url.com/)
工作正常。再次感谢

os.system()
返回退出代码,而不是实际的标准输出。查看
Popen
os.system()的返回值仅仅是执行状态-此函数不允许您访问命令的标准输入/输出。您需要
子流程
模块中的各种函数中的一个来执行此操作。看起来您都是正确的。将结果更改为
子流程。检查输出(“curl-shttp://path.to.url.com/)
工作正常。再次感谢!这与tkinter无关,tkinter只是显示您告诉它的内容。
results=os.system("curl -s http://path.to.url.com/")
        Label(mGui,text=str(results)).place(x = 10, y = 10 )