Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10062
  • 博文数量: 10
  • 博客积分: 360
  • 博客等级: 一等列兵
  • 技术积分: 70
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-04 11:04
文章分类
文章存档

2011年(1)

2010年(3)

2009年(6)

我的朋友
最近访客

分类: Python/Ruby

2010-06-24 14:14:03

使用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) |
给主人留下些什么吧!~~