2011-09-30 31 views
-2

我怎樣才能使用ctypes編寫複製下面的定義?Ctypes定義

unsigned char* x = new unsigned char[10]; 

謝謝。

+1

ctypes用於互操作。您需要描述參數如何傳遞。但char *通常映射到'c_char_p'。 –

+0

這個問題是上一個問題[這裏]的一部分(http://stackoverflow.com/questions/7513269/calling-dll-functions-using-python-ctypes)。謝謝。 – Martin

+0

你的問題(這一個和前一個)沒有任何意義。將C代碼轉換爲Python時,不需要使用ctypes。當你想從Python調用本地代碼時,你需要ctypes。本地代碼在哪裏? –

回答

1

根據您需要如何使用x,您可能需要ctypes.create_string_buffer

x = ctypes.create_string_buffer(' ' * 10);