Writing to a file

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Mar 25 21:49:31 EDT 2011


jyoung79 at kc.rr.com wrote:

>>>>import os
>>>>os.system('echo "Testing a... b... c..." > "~/Desktop/test2.txt"')

This is like going out the back door, getting a ladder out of
the shed and climbing through your bedroom window to get into
bed at night, instead of just using the stairs.

Use open/write/close. It's much more direct and efficient.

-- 
Greg



More information about the Python-list mailing list