dsf11t5u1651
2018-11-25 13:49
浏览 210
已采纳

golang与PHP / Ruby的unpack(“ C *”,。)等效吗?

Been searching around, still new to golang, PHP and ruby have an unpack function that unpacks a binary into an array. I'm trying to figure out how to do the following in golang.

$test = "\01\00\02\03";
print_r(unpack("C*", $test)); // [1,0,2,3]

Or

s = "\01\00\02\03"
arr = s.unpack("C*")
p(arr) # [1,0,2,3]

What's the best approach to doing this using golang?

图片转代码服务由CSDN问答提供 功能建议

在搜索时,仍然是golang的新手,PHP和ruby具有将二进制文件解压缩为数组的解压缩功能。 我正在尝试找出如何在golang中执行以下操作。</ p>

  $ test =“ \ 01 \ 00 \ 02 \ 03”; 
print_r(unpack(“ C  *“,$ test));  // [1,0,2,3] 
 </ code> </ pre> 
 
 

或</ p>

  s =“ \ 01 \ 00  \ 02 \ 03“ 
arr = s.unpack(” C *“)
p(arr)#[1,0,2,3] 
 </ code> </ pre> 
 
 

是什么 最好的方法来使用golang?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题