How To Decode Following Bytes In Python 3
in Python 3, used socket.recv() to get data from hardware, and get bytes: b'\x00\x004\x00\x08\x00\x00\x00The Delta Wavelength (nm) is currently set to 0.008.\xfc\xa9\xf1\xd2Mb\x80?
Solution 1:
Wat information do you need? because if you only need the part:
The Delta Wavelength (nm) is currently set to 0.008.
Then you could just do something like:
data = socket.recv()[8:60].decode("utf-8")
or faster with memoryview
data = memoryview(socket.recv())[8:60].decode("utf-8")
I'm assuming you don't need the hardware's meta-data
Post a Comment for "How To Decode Following Bytes In Python 3"