java字节数组转python字符串

java返回json对象, 其中一段话是 数组

json.dump 后的结果中
s = [-53, -75, -61, -9, -93, -70, 10, -69, -68, -43, -33, -52, -75, -59, -32, -47, -8, -54, -79, -51, -84, -54, -79, -53, -51, -68, -20, -52, -75, -51, -65, -58, -84, -93, -84, -58, -28, -42, -48, 87, 66, 67, 32, 60, 32, 49, 48, -72, -10, 47, 76, 80, 70, -93, -84, -55, -49, -58, -92, -49, -72, -80, -5, 62, 32, 50, 53, -72, -10, 47, 76, 80, 70, -95, -93, -67, -31, -70, -49, -59, -32, -47, -8, -57, -23, -65, -10, -93, -84, -65, -68, -62, -57, -79, -22, -79, -66, -64, -76, -44, -76, -45, -38, -55, -49, -70, -12, -50, -4, -75, -64, -93, -84, -57, -21, -63, -39, -76, -78, -67, -31, -70, -49, -69, -68, -43, -33, -54, -75, -68, -54, -57, -23, -65, -10, -65, -68, -62, -57, -95, -93]


def twoscomplement_to_unsigned(i):
    return i % 256

str = bytes(map(twoscomplement_to_unsigned, s)).decode('gb2312')

来源 How to convert java byte[] to python string?
](https://stackoverflow.com/questions/40951213/how-to-convert-java-byte-to-python-string)

你可能感兴趣的:(java字节数组转python字符串)