def writeFileText(fileName, fileText, writeMode='w+'):
 try:
  file = open(fileName, writeMode)
  file.write(fileText)
  file.close()
 except IOError:
  print (('The file ' + fileName) + ' can not be written to.')

def writeFileText ( fileName , fileText , writeMode = 'w+' ) : try : file = open ( fileName , writeMode ) file . write ( fileText ) file . close ( ) except IOError : print ( ( 'The file ' + fileName ) + ' can not be written to.' )
write a text to a file .