作者KSJ (阿真)
看板Python
标题Re: [问题] 从c传一个struct到python?
时间Fri Jul 24 23:48:16 2009
※ 引述《giveatry (new life)》之铭言:
: 请教板上大大
: 我有一个python程式
: 会呼叫一个c的function
: 这个c function执行完之後
: 会产生一个structure,大概像这样
: person{
: int age;
: char* name;
: }
: 请问一下我要怎麽传回python?
水球你你不在 回个文
有点忘了 不过大概是下面这样子
在c里 最後就
return Py_BuildValue("is",person.age , person.name);
在python端就 如果你的function叫 Fperson 就
随便生个python变数 例如 personPY
(personPY.age , personPY.name)=Fperson()
就有类似structure的东西了
如 personPY.age 就是c里的person.age 了
: python要怎麽收这个struct?
: 有办法做到吗?
: 谢谢
不知道是不是问这个…
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.63.180
1F:推 giveatry:感谢,明天来试试 07/25 22:44