使用np.savetxt写入不覆盖原有内容,连续写入,循环写入

import numpy as np

with open('eye.txt','ab') as f:
    newresult1 = np.random.rand(2, 3) 
    newresult2 = np.random.rand(2, 3) 
    np.savetxt(f, newresult1, delimiter=" ") 
    np.savetxt(f, newresult2, delimiter=" ") 

with open('eye.txt','ab') as f: 这句是灵魂

txt里面有两个变量 newresult1和newresult2

使用np.savetxt写入不覆盖原有内容,连续写入,循环写入_第1张图片

你可能感兴趣的:(numpy)