Using The Python/c Api To Get The Values Of Pystrings In The Interpreter As Cstrings Within A C Program
I've been messing around with the Python/C API and have this code: #include #include #include int main(int argc, char *argv[]) {
Solution 1:
You need to use PyString_AsString. I think it goes something like this:
PyObject* module = PyImport_AddModule("__main__");
PyObject* o = PyObject_GetAttrString(module , "__NAME__");
if (PyString_Check(o))
{
const char* name = PyString_AsString(o);
// don't delete or modify "name"!
}
Py_DECREF(o);
Baca Juga
- How Can I Use Kubernetes Python Api To Get Clusters Information?
- Raise Imgurclienterror('json Decoding Of Response Failed.') Imgurpython.helpers.error.imgurclienterror: Json Decoding Of Response Failed
- How To Add Condition For Particular Class To Show Field Drop -down Except Partner_id From Res.partner Form
Post a Comment for "Using The Python/c Api To Get The Values Of Pystrings In The Interpreter As Cstrings Within A C Program"