I have this byte represented as string:
b'google-site-verification=pFgmIQ6qK3YjcRAAhsKiPzmEiOVcynQslFMEba5lXvs'
I want to convert it to a raw string looking like this:
r'"google-site-verification=pFgmIQ6qK3YjcRAAhsKiPzmEiOVcynQslFMEba5lXvs"
(without the r' displaying on printing)
I tried it with replace but can't figure out to get it to work. Maybe someone can help me here.
Greetings
Edit full code:
def decode_txt_rdata(rdata, rdlen):
"""decode TXT RR rdata into a string of quoted text strings,
escaping any embedded double quotes"""
txtstrings = []
position = 0
while position < rdlen:
slen, = struct.unpack('B', rdata[position:position+1])
s = rdata[position+1:position+1+slen]
s = '"{}"'.format(s.replace(b'"', b'"').decode())
txtstrings.append(s)
position += 1 + slen
return ' '.join(txtstrings)