How do I convert a PyObject to string in C++?

L

lixinyi.23

I have a PyObject, say 'Hello World' , a string,
How do I convert it to a string in C++?
Thanks in advance!
 
A

Aaron \Castironpi\ Brady

I have a PyObject, say 'Hello World' , a string,
How do I convert it to a string in C++?
Thanks in advance!

Look at PyString_AsStringAndSize . It gives you a pointer to a buffer
and a size. Allocate a new one and copy it if you need to modify it,
or you want a copy that outlives the object version.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top