【发布时间】:2018-10-25 19:39:51
【问题描述】:
我尝试使用以下方法将字符串从 c++ 发送到 python 字符串:
PyObject* pyString = PyUnicode_FromString("/abc/def.html/a%22.php?abc=&def=%22;%00s%01");
....
PyObject* pyArgs = Py_BuildValue("(z)", pyString);
...
PyObject_CallObject(pFunc, pyArgs);
但在脚本中字符串不好:
function(data):
print(data)
结果是:
/abc/def.html/a bogus %pp?abc=&def= %;(null)%
发生了什么事?,如果我尝试使用 %% 转义 % 字符可以正常工作,但 PyUnicode_FromString 不是 printf 格式。
这是 PyUnicode_FromString 函数的错误吗?,我需要原生 python 转义吗?还是需要手动转义?
【问题讨论】:
标签: c++ python-3.x c++11 python-c-api