python读取二进制文件_如何用python读取二进制文件?
我發(fā)現(xiàn)用Python讀取二進(jìn)制文件特別困難。你能幫我一把嗎?我需要讀取這個(gè)文件,在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)
詳細(xì)地說,文件格式是: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來讀這個(gè)?我什么都試過了,但都沒成功。有沒有可能在python中使用F90程序,讀取這個(gè)二進(jìn)制文件,然后保存我需要使用的數(shù)據(jù)?
總結(jié)
以上是生活随笔為你收集整理的python读取二进制文件_如何用python读取二进制文件?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gdb 调试_GDB调试指南-源码查看
- 下一篇: python urllib发送post请