title: Python : removing "\n" from a file name
body: <p>Here I am creating a program to create a file named current directory+url+system date and time .txt
  On using netloc to extract only flipkart from <a href="http://www.flipkart.com" rel="nofollow">http://www.flipkart.com</a> file created contains \n. How to remove \n from the file.</p>
  
  <pre><code>class FileHandler(object):
  
      def create_file(self,url):
          print 'creating file....'
          flipkart = urlparse(url)
          filename = flipkart.netloc
  
  
  
          #filename = dns.name.from_text(url).split(3)[1].to_text(omit_final_dot=True)
          #filename = dns.name.from_text(url).split('www.')[1].to_text(omit_final_dot=True)
          #str.split(sep=None, maxsplit=-1)
          print 'file is---'
          print filename
          #filename = url
          dir = os.getcwd()
  
          #print 'Current directory path is-'
          #print dirPath
  
  
          date = datetime.datetime.now()
          now = date.strftime("%Y-%m-%d %H-%M")
          dirPath = os.path.join(dir,filename)
          dirPath.replace("\n","-")
          #filenameCreated = dirPath + now
          filenameCreated = dirPath + now
          #filenameCreated = filenameCreated1.splitlines()
          print filenameCreated
          f = self.openfile(filenameCreated + '.txt', 'a')
          #readFile(f)
          return f
          #self.writeFile(f)
  
  
  
  #defining openfunction
      def openfile(self,filename,mode):
          try:
              open(filename,mode)
  
          except Exception, err:
              print("File cannot be opened.")
              print(str(err))
          return
  </code></pre>