[英]How to pass Python's keyword arguments with pybind11?
Given this function: __init__(username, password, **kwargs)
with these keyword arguments: 给定此功能: __init__(username, password, **kwargs)
具有以下关键字参数:
auto_patch: Patch the api objects to match the public API. auto_patch:修补api对象以匹配公共API。 Default: False 默认值:False
drop_incompat_key: Remove api object keys that is not in the public API. drop_incompat_key:删除不在公共API中的api对象密钥。 Default: False 默认值:False
timeout: Timeout interval in seconds. timeout:超时间隔,以秒为单位。 Default: 15 默认值:15
api_url: Override the default api url base api_url:覆盖默认的api URL库
cookie: Saved cookie string from a previous session cookie:上一个会话中保存的cookie字符串
settings: A dict of settings from a previous session 设置:上一个会话的设置命令
on_login: Callback after successful login on_login:成功登录后的回调
proxy: Specify a proxy ex: ' http://127.0.0.1:8888 ' (ALPHA) proxy:指定一个代理,例如:' http : //127.0.0.1 : 8888 '(ALPHA)
proxy_handler: Specify your own proxy handler proxy_handler:指定您自己的代理处理程序
I want to embed python in my C++ application with pybind11. 我想使用pybind11将python嵌入我的C ++应用程序中。 How do I pass the keyword arguments? 如何传递关键字参数? I am this far: 我到此为止:
#include <pybind11/embed.h> // everything needed for embedding
#include <iostream>
namespace py = pybind11;
int main()
{
py::scoped_interpreter guard{}; // start the interpreter and keep it alive
py::module calc = py::module::import("calc");
py::object result = calc.attr("__init__")("IGname", "IGpassword");
int i;
std::cin >> i;
}
I have found the right documentation: https://pybind11.readthedocs.io/en/stable/advanced/pycpp/object.html 我找到了正确的文档: https : //pybind11.readthedocs.io/en/stable/advanced/pycpp/object.html
I cannot test it as I have some other issues occurring but that is the place to go. 我无法测试它,因为发生了其他一些问题,但这是可以解决的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.