在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
先安装一下包管理工具 yum install luarocks lua-devel -y luarocks install lpack ln -s /usr/lib64/lua /usr/local/lib 指定luarocks安装路径参数备忘 luarocks install lpack --tree=/usr/local/lib64 测试一下包安装有没有问题 /usr/local/openresty/bin/resty -e "require 'pack'" 我想是没有问题了,,顺便测试一下pack
require"pack" bpack=string.pack bunpack=string.unpack function hex(s) s=string.gsub(s,"(.)",function (x) return string.format("%02X",string.byte(x)) end) return s end a=bpack("Ab8","\027Lua",5*16+1,0,1,4,4,4,8,0) --print(hex(a),string.len(a)) b=string.dump(hex) b=string.sub(b,1,string.len(a)) print(a==b,string.len(b)) print(bunpack(b,"bA3b8")) i=314159265 f="<I>I=I" a=bpack(f,i,i,i) --print(hex(a)) print(bunpack(a,f)) i=3.14159265 f="<d>d=d" a=bpack(f,i,i,i) --print(hex(a)) print(bunpack(a,f))
|
请发表评论