Hi, I'm trying to
append computed values to an output file at defined solution intervals.
All the documentation and tutorials on python seem to write charachter strings
instread of computed values.
Here is a test
case. Anyone have some tips on what to replace " 'Here I want the VALUES
of t, r, l and d, but only can seem to get a single string to work like this
one!' " with to get the values of t, r, l and d?
>>>t=0
>>>logfile = open('log.dat', 'w') # opens a file to write to
>>>logfile.write('t, r, l, d' "\n") #Hooray, this works, I get a header!
>>>logfile.close() # should I leave it open for efficiency?
>>>while t<10:
>>> r=t-1*123
>>> l=342/r
>>> d=(87-r)*l
>>> t = t+1
>>> logfile = open('log.dat','a') # the 'a' allows you to append to your file
>>> logfile.write('Here I want the VALUES of t, r, l and d, but only can seem to get a single string to work like this one!' "\n")
>>>logfile.close()
>>>logfile = open('log.dat', 'w') # opens a file to write to
>>>logfile.write('t, r, l, d' "\n") #Hooray, this works, I get a header!
>>>logfile.close() # should I leave it open for efficiency?
>>>while t<10:
>>> r=t-1*123
>>> l=342/r
>>> d=(87-r)*l
>>> t = t+1
>>> logfile = open('log.dat','a') # the 'a' allows you to append to your file
>>> logfile.write('Here I want the VALUES of t, r, l and d, but only can seem to get a single string to work like this one!' "\n")
>>>logfile.close()
Thanks in advance!
Buddy
This message and any attachments are intended for the individual or
entity named above. If you are not the intended recipient, please
do not forward, copy, print, use or disclose this communication to
others; also please notify the sender by replying to this message,
and then delete it from your system. The Timken Company / The
Timken Corporation
