I know that java and python handle bytes differently so I am a little bit confused about how to convert byte[] to python string I have this byte[] in java
{ 118, -86, -46, -63, 100, -69, -30, -102, -82, -44, -40, 92, 0, 98, 36, -94 }
I want to convert it to python string here is how i did it
b=[118, -86, -46, -63, 100, -69, -30, -102, -82, -44, -40, 92, 0, 98, 36, -94]
str=""
for i in b:
str=str+chr(abs(i))
But I am not really sure if this is the correct way to do it.
byteis a datatype in java that does not correspond to python bytestrings. While you can get a result from this, it is likely meaningless.intto astr.b=[118, ...]. Your real question is probably more like "How do I convert a Python list to a string?", or maybe "How do I convert many Python integers to a string?". The first is probably eitherstr(b)orrepr(b); the second is something like' '.join(str(x) for x in b). See also the docs forstr.join.