"abcd123".each_byte do |byte | printf(" %-08s",byte.to_s(2)) end
想输出
0110 0001 0110 0010 0110 0011 0110 0100 0011 0001 0011 0010 0011 0011
"abcd123".each_byte do |byte | printf(byte.to_s(2).rjust(8,'0')+" ") end
"abcd123".each_byte do |byte | printf(" %08b", byte) end
"abcd123".unpack('B*').first.scan /(.{4})(.{4})/ do |a,b| print "#{a} #{b} " end