0
이상한 문제가 있습니다. 파일에서 문자열을 대체하려고 할 때.은 파이썬을 사용하여 파일 내의 문자열을 대체합니다.
lattice parameter A [a.u.]
5.771452243459
나는로 대체하는 것을 시도하고있다 : 파일의 관련 행은
가with open(newsys, "r+") as finp:
for line in finp:
# print(line)
if line.startswith("lattice parameter A [a.u.]"):
line = next(finp)
print(line)
print(Alat)
line.replace(line.strip(), str(Alat))
print(line)
지난 3 인쇄 문이 제공 : 무엇이 잘못 가고
5.771452243459 # string that will be replaced
6.63717007997785 #value of Alat
5.771452243459 #the line after replace statement
이리?