我有一些 PHP 代码,类似于下面显示的代码,它建立连接并获得响应(来自 Web 服务)。
我将如何在 Python 中做类似的事情?
$cObj = curl_init();.
curl_setopt($cObj, CURLOPT_URL,$this->urlws.'/trlink/link1/trlink');
curl_setopt($cObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cObj, CURLOPT_TIMEOUT, 20);
curl_setopt($cObj, CURLOPT_HTTPHEADER, array());
curl_setopt($cObj, CURLOPT_POST, 1);
curl_setopt($cObj, CURLOPT_POSTFIELDS,"XMLString=".$xml);
$this->xml_response = curl_exec($cObj);.