Jan-01-2020, 10:04 PM
Hallo,
I have a small programm. In a function I receive date an decode it back to utf-8
the function returns the data:
b'this ist the text\nthis is more text'
If I try to
How can I print my data?
Thank you for your help
Martin
I have a small programm. In a function I receive date an decode it back to utf-8
the function returns the data:
def reliable_recv():
data = ""
while True:
try:
data = data + target.recv(1024).decode('utf-8')
return json.loads(data)
except ValueError:
continueif I print the data it's printed like that: b'this ist the text\nthis is more text'
If I try to
result = reliable_recv() print(result.decode())I get the error
Error:AttributeError: 'str' object has no attribute 'decode'so my question: How can I print my data?
Thank you for your help
Martin
