我试图将一些使用readBin函数(R)的代码转换成Python。在
R代码:
datFile = file("https://stats.idre.ucla.edu/stat/r/faq/bintest.dat", "rb")
i<-readBin(datFile, integer(), n = 4, size=8, endian = "little", signed=FALSE)
print(i)
退货:
^{pr2}$我在Python中的尝试:
^{3}$退货:
8589934593
如何在Python中获得相同的输出(我知道我缺少n参数,但我找不到正确实现它的方法)。在
谢谢
试试这个:
或者你可以把它作为一个函数。有些参数目前没有使用,请稍后工作:)
^{pr2}$下面是用法:
供您检查的一些链接:
Working with binary data
Reading binary file
相关问题 更多 >
编程相关推荐