blublu
V2EX  ›  问与答

Python 在使用 ctypes 调用 c++ 如何传递字节数组的问题

  •  
  •   blublu · Mar 18, 2017 · 1649 views
    This topic created in 3437 days ago, the information mentioned may be changed or developed.

    因为一些需要,需要调用 .so 来保存文件。但是 python 读取文件二进制流后得到 bytes 之后该如何把整个文件的 stream 传递给 C 函数呢? C 函数接受的方式是 char*. 折腾了半年没找到解决方案。不知有谁能指点一二么?

    2 replies    2017-03-19 09:18:13 +08:00
    sagaxu
        1
    sagaxu  
       Mar 18, 2017
    ctypes.c_char_p
    zsz
        2
    zsz  
       Mar 19, 2017 via iPhone
    看这篇文章 http://www.cnblogs.com/btchenguang/archive/2012/09/04/2670849.html

    有问题可以加我们的群问,这样效率更高,这个群是一群工程师组建的面向初学者的 python Linux 学习群, qq 群号: 278529278 ,非商业性质,拒绝广告,只接收真正想学这方面技术的朋友,交流学习,申请请说明来自 v2ex
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2757 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 02:24 · PVG 10:24 · LAX 19:24 · JFK 22:24
    ♥ Do have faith in what you're doing.