使用struct,相当轻松
import struct
def htonll(Val):
strNative = struct.pack('Q', Val)
BEVal = struct.unpack('!Q', strNative)[0]
return BEVal
def ntohll(Val):
strBE = struct.pack('!Q', Val)
NativeVal = struct.unpack('Q', strBE)[0]
return NativeVal
阅读(404) | 评论(0) | 转发(0) |