注:这里我的 PyBind11 源码下载到了../pybind11目录,系统使用的是 Python 3.8,通过apt install python3-dev安装的 Python C API。 然后运行python3 -c 'import example; help(example)'可以看到相应文档: Helponmoduleexample: NAME example-pybind11 example plugin FUNCTIONSadd(...)methodofbuiltins.PyCapsule ...
>>>importexample>>>help(example.add3) Help on built-infunction add3inmodule example: add3(...) method of builtins.PyCapsule instance add3(i:int=1, j:int=2) ->intA function which adds two numbers>>>example.add3()3>>>example.add3(3)5>>>example.add3(j=3)4>>> 导出变量 在pyb...
复制 >>>importexample>>>help(example.add3)Help on built-infunctionadd3inmodule example:add3(...)methodofbuiltins.PyCapsule instanceadd3(i:int=1,j:int=2)->intAfunctionwhich adds two numbers>>>example.add3()3>>>example.add3(3)5>>>example.add3(j=3)4>>> 导出变量 在pybind11通过py:...
Thisisa messagefromC++library!>>>help(hello.say_hello)Help on built-infunction say_helloinmodule hello:say_hello(...)method of builtins.PyCapsule instance say_hello(name:str='Jack')->NonePrint hello to the name.(END) py::arg参数还有一种简化写法,通过引入名称空间pybind11::literals,可以使用...
help(example) FUNCTIONS add(...) method of builtins.PyCapsule instance add(i: int, j: int) -> int A function which adds two numbers ## 默认参数 使用arg扩展 // shorthandm.def("add",&add,"A function which adds two numbers",py::arg("i")=1,py::arg("j")=2);或// shorthandm....