上次是wxwidget,這次又發現乙個curl。python版本分別叫做wxpython和pycurl。
wxwidget並不能算是乙個特別牛的庫,至少介面設計上還是mfc級別的,對xml也沒有能用的支援,拼個介面很累。但是你猜不到的是,就這麼爛的介面,用python寫出來的程式依然不長。
還有人用python寫win32的視窗程式,也不長。
今天用到個libcurl,把c++版的測試**和python版本貼出來對比一下。
import pycurl
import stringio
url = ""
crl = pycurl.curl()
crl.setopt(pycurl.verbose,1)
crl.setopt(pycurl.followlocation, 1)
crl.setopt(pycurl.maxredirs, 5)
crl.fp = stringio.stringio()
crl.setopt(pycurl.url, url)
crl.setopt(crl.writefunction, crl.fp.write)
crl.perform()
print crl.fp.getvalue()
#include "curl/curl.h"
#pragma comment(lib, "libcurl.lib")
long writer(void *data, int size, int nmemb, string &content);
bool curlinit(curl *&curl, const char* url,string &content);
bool geturldatabycurl(const char* url, string &content);
void main()
getchar();
}bool curlinit(curl *&curl, const char* url,string &content)
code = curl_easy_setopt(curl, curlopt_errorbuffer, error);
if (code != curle_ok)
curl_easy_setopt(curl, curlopt_verbose, 1l);
code = curl_easy_setopt(curl, curlopt_url, url);
if (code != curle_ok)
code = curl_easy_setopt(curl, curlopt_followlocation, 1);
if (code != curle_ok)
code = curl_easy_setopt(curl, curlopt_writefunction, writer);
if (code != curle_ok)
code = curl_easy_setopt(curl, curlopt_writedata, &content);
if (code != curle_ok)
return true;
}long writer(void *data, int size, int nmemb, string &content)
bool geturldatabycurl(const char* url, string &content)
if ( !curlinit(curl,url,content) )
code = curl_easy_perform(curl);
if (code != curle_ok)
long retcode = 0;
code = curl_easy_getinfo(curl, curlinfo_response_code , &retcode);
if ( (code == curle_ok) && retcode == 200 )
else
curl_easy_cleanup(curl);
return false;
}
說python開發快的都是廢話,這能不快嘛!!!!!!
迭代器是神馬東西
一 迭代器用來幹嘛的?本質是指標,用來遍歷訪問容器中元素的。stl實現了容器和演算法的分離,如何實現的呢,答曰用類模板和函式模板,也可理解為所謂的泛化。那麼容器和演算法又是怎樣結合在一起的呢,答曰迭代器 使用演算法時,傳給演算法的是迭代器!二 迭代器常用運算。所有標準庫容器的迭代器都提供 iter ...
task struct到底是個神馬東西?
上回我們說到了常用的作業系統程序排程演算法,學過作業系統的同學應該都知道作業系統的四大職能 程序管理 記憶體管理 裝置管理以及檔案系統的管理。那麼最重要的職能之一 程序管理,是如何進行的呢?首先在要管理乙個程序的時候,我們需要知道某個程序的具體資訊,比如程序的pid 優先順序等等,所以我們就需要乙個...
咦,神馬東西晃到洒家了
咦,神馬東西晃到洒家了?2011年12月27日 耀眼的東西總能吸引人,比如人民幣,比如美女。要想讓那些不那麼耀眼,建議出門時請帶好墨鏡。墨鏡 是個好東西,能沖淡些光,讓咱少些刺激。你們受的刺激還少莫?反正我是受夠了,好的 不好的 呵呵,多少有點意思。但俺們有時也俗,因為不俗俺們就好像沒有活下去的必要...