I need the output in a text file with specific arrangements.eg,
0.2500000 0.2500000 0.0000000 1.0000000
0.2400000 0.2400000 0.0000000. 1.0000000
so I use a code as
#!/usr/bin/env python2
import numpy as np
import numpy as np
import math
kz=0.0000000
kx = 0.0000000
ky = 0.0000000
theta=0.01000
K =[kx, ky, kz, 1.00000000]
for i in np.arange (-0.2500000,0.2500000,theta):
print kx+i,ky+i, kz,1000000
how can I add spaces and can get desired digits in output values?
To print to a file you could do:
f = open("demofile2.txt", "a")
for i in np.arange (-0.2500000,0.2500000,theta):
f.write((kx + i) + " " + (ky+ i) + " " + kz + " " + 1000000 + " \n")
f.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.