2
I have a physical simulation code that I deal with LOTS OF INFORMATION and lots of interactions. For example, I have the calculation of the Qt load, however, it is 100 interactions and I am working with a Qt vector of size 101! I need to save the data of this Qt for each interaction I have in a file . txt:
f2.write('%.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f\n'
%(qt[0],qt[1],qt[2],qt[3],qt[4],qt[5],qt[6],qt[7],qt[8],qt[9],qt[10]))
This is an example of when I have 10 Qt’s. How would I generalize this so that I don’t need to write 101 times the '%.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f \t %.20f\n'
?
This "text_file" suggests the name you gave the file when you gave the command "f=open...."?
– Bernardo Cecchetto
@Bernardocecchetto No, the
texto_arquivo
represents the line of text that is written to the file. It’s just a variable to get a little more organized. It’s the difference between doingf2.write('a')
versustexto = 'a'; f2.write(texto)
. They turn out to be two different ways of doing the same.– Isac
got it, thanks!
– Bernardo Cecchetto