【问题标题】:Importing C file with python bindings in python file在 python 文件中导入带有 python 绑定的 C 文件
【发布时间】:2026-02-15 15:15:01
【问题描述】:

有一个用 C 编写的很棒的程序,它还包含使用 python 绑定到 python 的转换。不过我想用绑定来扩展文件以赋予它更多功能。

当我尝试在使用绑定的 python 文件中将 'import bounded_file' 更改为 'import my_bounded_file' 时,我得到一个文件未找到错误。所以我的问题是如果 .c 文件包含 python 绑定,我如何将 .c 文件导入 .py 程序?

谢谢!

【问题讨论】:

    标签: python c import binding


    【解决方案1】:

    C 文件需要编译成共享库。然后,你导入这个库。

    【讨论】:

      最近更新 更多