1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > python存储numpy数据为文件_numpy.savetxt是否将数组保存到文件中的特定位置?

python存储numpy数据为文件_numpy.savetxt是否将数组保存到文件中的特定位置?

时间:2022-12-01 16:18:08

相关推荐

python存储numpy数据为文件_numpy.savetxt是否将数组保存到文件中的特定位置?

我有一个file.txt形式:; In this topology include file, you will find position restraint

; entries for all the heavy atoms in your original pdb file.

; This means that all the protons which were added by pdb2gmx are

; not restrained.

[ position_restraints ]

; atom type fx fy fz

1 1 1000 1000 1000

5 1 1000 1000 1000

7 1 1000 1000 1000

10 1 1000 1000 1000

12 1 1000 1000 1000

13 1 1000 1000 1000

14 1 1000 1000 1000

16 1 1000 1000 1000

(如果您感兴趣,这是来自gromacs的位置限制文件)

在Python中,我有一个数字阵列整数[2, 4, 7, 8, 9, 10, 15, 108]。我想将file.txt替换为:

^{pr2}$

也就是说,file.txt内的表的第一列将被我在Python中定义的整数数组替换。请注意列中的对齐方式是如何被尊重的。这很重要。在

我该怎么做?我在问题标题中使用了numpy.savetxt,因为它与我想做的很接近,但我认为{}本身无法做到。在

我该怎么做?在

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。