Jump to content
Sign in to follow this  
maomao2028

[help] how to convert delphi TBytes to python Bytes

Recommended Posts

In delphi, with the help of p4d's mainmodule.xxx(v), the python function is called, where the v input is the bytes type, how to convert Tbytes to bytes type in Delphi

Share this post


Link to post
Posted (edited)

Look at PyBytes_AsString, or PyBytes_AsStringAndSize functions.

 

For example if obj is a bytes PPyObject. the following converts it to an AnsiString.

  AnsiString(PyBytes_AsString(obj))

 

Also PyObjectAsVariant(obj) converts it to a variant.

 

In the opposite direction to create a bytes object in Delphi use PyBytes_FromStringAndSize

Edited by pyscripter

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×