Opening and writing to a file. : write « File « Python Tutorial






import sys

try:
   file = open( "clients.dat", "w" )  
except IOError, message:              
   print >> sys.stderr, "File could not be opened:", message
   sys.exit( 1 )

print >> file, "account"
      
file.close()








12.16.write
12.16.1.write(string)
12.16.2.Writing to Files
12.16.3.Opening and writing to a file.