Linxing
0.85D
V2EX  ›  问与答

一段 Java 代码 转换成 Python 代码的问题

  •  
  •   Linxing · Mar 12, 2018 · 1428 views
    This topic created in 2994 days ago, the information mentioned may be changed or developed.
    public static byte[] marshallInt(int num,int length) {
    byte[] byteStream = new byte[length];
    for (int i = 0; i < length; i++) {
    byteStream[i] = (byte) (num >>> ((length-1)*8 - i * 8));
    }
    return byteStream;
    }


    byte length[]=marshallInt(sendmsg.length(),2);


    ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
    baos1.write(length);
    baos1.write(sendmsg.getBytes());
    byte[] bufferOut = baos1.toByteArray();
    socketOut.write(bufferOut);

    Python 的字节数组要怎么整 环境是 Python2.7
    能力有限 搜了一圈 都没有想明白要怎么转换
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2219 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 00:33 · PVG 08:33 · LAX 17:33 · JFK 20:33
    ♥ Do have faith in what you're doing.