title: How do you open a file with a space in its name?
body: <p>Here is my code:</p>
  
  <pre><code>from Tkinter import *
  import os
  from tkFileDialog import askopenfilename
  
  def openfile():
      Tk().withdraw()
      filename = askopenfilename()
      os.system("open " + filename)
      print(filename)
  
  
  root = Tk()
  button = Button(root, text="Choose File", command=openfile)
  button.pack()
  
  root.mainloop()
  </code></pre>
  
  <p>In short, this seems to work on any file except for files with <em>a space</em> in their name. </p>
  
  <p>I've tried executing the code above from my terminal and I get an error due to the space in the name of the file. It seems it has split the file name into two different names, and it has tried to open files that don't even exist (corresponding to those split names).</p>
  
  <h3>Example of error</h3>
  
  <blockquote>
    <p>The files /Users/dylanrichards/Desktop/boot and /Users/dylanrichards/Desktop/strap.css do not exist. </p>
  </blockquote>
  
  <p>The filename in this example was <code>boot strap.css</code>.</p>
  
  <p>If anyone can answer this, it would be greatly appreciated...</p>
  
  <p>Here's the screenshot of the output of the command <code>cat text-opener.py</code>, where <code>text-opener.py</code> is the my Python script that I'm trying to execute.</p>
  
  <p><a href="https://i.stack.imgur.com/OVVtL.png" rel="nofollow noreferrer">Terminal Screenshot</a></p>