Answer the question
In order to leave comments, you need to log in
Is there an analogue of Python's struct.pack in ruby?
Good day.
There is a python code:
import struct
struct.pack('!3i32xhbbi48x', 442,1627896903,1,8054,0,0,0)
b'\x00\x00\x01\xbaa\x07\xbcG\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1fv\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
[442,1627896903,1,8054,0,0,0].pack('!3i32xhbbi48x')
Traceback (most recent call last):
22: from /home/deployer/.rvm/gems/[email protected]_fancy_app/bin/ruby_executable_hooks:22:in `'
21: from /home/deployer/.rvm/gems /[email protected]_fancy_app/bin/ruby_executable_hooks:22:in `eval'
20: from /home/deployer/.rvm/gems/[email protected]_fancy_app/bin/irb:23:in `'
19 : from /home/deployer/.rvm/gems/[email protected]_fancy_app/bin/irb:23:in `load'
18: from /home/deployer/.rvm/gems/[email protected]_fancy_app /gems/irb-1.3.6/exe/irb:11:in `'
1: from (irb):45:in `'
:134:in `pack': too few arguments (ArgumentError)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question