Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.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 子流程popen+;卷曲度+;二进制数据_Python_Curl_Popen - Fatal编程技术网

Python 子流程popen+;卷曲度+;二进制数据

Python 子流程popen+;卷曲度+;二进制数据,python,curl,popen,Python,Curl,Popen,以下语句按预期工作: os.system("curl --data-binary \@"+input_file_path+" -o "+ file_name +" localhost:30") 但在使用subprocess.popen尝试时: Popen(['curl','--data-binary','\@'+input_file_path, '-o', file_name,'localhost:30'], stdout=PIPE).communicate()[0] Curl似乎挂起了(登

以下语句按预期工作:

os.system("curl --data-binary \@"+input_file_path+" -o "+ file_name +" localhost:30")
但在使用
subprocess.popen
尝试时:

Popen(['curl','--data-binary','\@'+input_file_path, '-o', file_name,'localhost:30'], stdout=PIPE).communicate()[0]
Curl似乎挂起了(登录到无止境的循环中),就像没有将输入文件传递给它一样(这是localhost:30正常运行所必需的)


有什么想法吗?

您可以尝试使用
subprocess.Popen
中的原始字符串以及
shell=True的
Popen
的附加关键字参数:

subprocess.Popen("curl --data-binary \@"+input_file_path+" -o "+ file_name +" localhost:30",
    stdout=subprocess.PIPE,
    shell=True)

您可以尝试在
subprocess.Popen
中使用原始字符串,并在
shell=True的
Popen
中添加关键字参数:

subprocess.Popen("curl --data-binary \@"+input_file_path+" -o "+ file_name +" localhost:30",
    stdout=subprocess.PIPE,
    shell=True)

不调用系统的curl如何

不调用系统的curl怎么样

因为有时您根本不想等待响应或等待,只需将fork分离并忘记即可。另一个好的http python库是''library,因为有时您根本不想等待响应或等待,只需fork detach并忘记即可。另一个好的http python库是“”库