0
我试图在python 3.3中使用C字符指针数据类型。我用下面的代码:在python中使用c数据类型与ctypes
from ctypes import *
firstname = c_char_p("I am a noob programmer".encode("utf-8"))
print(firstname.value)
我所需的输出是
I am a noob programmer
但我得到的是
b'I am a noob programmer'
我下面的Python 2.6制作的教程。我使用“ascii”作为编码函数的参数。并且还尝试了“字节()”而不是编码。但是在任何时候都没有什么区别。为什么我不能得到我想要的结果?以及如何根据需要获得输出。
请人帮助我理解..
输出对于Python 3是正确的。如果您希望看到与教程相同的输出,请使用Python 2.6。 – 2013-04-09 13:15:09