0

In Python 3.6 I am trying to reference a variable from outside to inside a byte object.

This is a section of my code that I have simplified to try and explain the point.

#set my variable here
RECORDID = 'MyRecordID'

#create a byte object where the RECORDID needs to be passed to
output_buffer1 = b"<?xml version=\"1.0\" encoding=\"UTF-8\"?><AMS<TransportControl><RecordCue ID=RECORDID /></TransportControl></AMS>"

My byte object is an essentially an XML string that I am passing to an external API, but I need to be able to put the RECORDID inside that XML string at this position

<RecordCue ID= here />

so that the result is

<RecordCue ID='MyRecordID' />

Basically, how do I reference that variable from within the byte object? I have tried putting a percent sign and a plus sign, brackets etc around the variable name but it wont work. It always outputs exactly what I type.

Any help would be greatly appreciated.

Thank you

yekootmada
  • 21
  • 3
  • 8

0 Answers0