python读取二进制文件_如何用python读取二进制文件?

我发现用Python读取二进制文件特别困难。你能帮我一把吗?我需要读取这个文件,在Fortran 90中,该文件很容易被int*4 n_particles, n_groups

real*4 group_id(n_particles)

read (*) n_particles, n_groups

read (*) (group_id(j),j=1,n_particles)

详细地说,文件格式是:Bytes 1-4 -- The integer 8.

Bytes 5-8 -- The number of particles, N.

Bytes 9-12 -- The number of groups.

Bytes 13-16 -- The integer 8.

Bytes 17-20 -- The integer 4*N.

Next many bytes -- The group ID numbers for all the particles.

Last 4 bytes -- The integer 4*N.

我如何用Python来读这个?我什么都试过了,但都没成功。有没有可能在python中使用F90程序,读取这个二进制文件,然后保存我需要使用的数据?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值