write a .txt file
Jia Hu
hujia06 at gmail.com
Mon Jul 12 21:28:06 EDT 2010
Hello:
I have a problem about how to generate a specific.txt file. I use the
following code:
#!/usr/bin/python
# OS: Ubuntu
import subprocess
fileName = open ('final.txt', 'a')
fileName.write ('%s %s %s \n' % (12,25,9))
desLrr = subprocess.Popen('echo "hello" >> final.txt ', shell=True)
fileName.seek(0,2)
fileName.write ('%s %s %s \n' % (85,25,12))
fileName.close()
The above code generates the following result:
12 25 9
85 25 12
hello
What I want is:
12 25 9
hello
85 25 12
Could someone provies some suggestions about this problem?
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100712/40b5eee8/attachment.html>
More information about the Python-list
mailing list