python implements an incremental save method for writing numeric filenames

  • 2021-01-03 20:56:13
  • OfStack

As shown below:


 col = []
 img = "test1"
 img1 = "test2"
 col.append(img)
 col.append(img1)
 data=np.array(col)
 np.savetxt('/public/home/student6/test/test.csv',data,fmt='%s')
 col=[]
 img2 = "test3"
 img3 = "test4"
 col.append(img2)
 col.append(img3)
 data=np.array(col)
 i = 1 
 np.savetxt('/public/home/student6/test/test'+'%d.csv'%i ,data,fmt='%s')

The main one is the following code snippet


np.savetxt('/public/home/student6/test/test'+'%d.csv'%i ,data,fmt='%s')

Related articles: