title: Saving file with apostrophe in the name (Python 3.4)
body: <p>Trying to save image files in batches. Works nicely, but the list of names for each file sometimes includes apostrophes, and everything stops. </p>
  
  <p>The offending script is:</p>
  
  <pre><code>    pic.save(r"C:\Python34\Scripts\{!s}.jpg".format(name))
  </code></pre>
  
  <p>The apostrophes in the names aren't a problem when I embed them in a url with selenium</p>
  
  <pre><code>    browser.get("https://website.com/{!s}".format(name))
  </code></pre>
  
  <p>or when I print the destination file name, e.g. </p>
  
  <pre><code>    print(r"C:\Python34\Scripts\{!s}.jpg".format(name))
  </code></pre>
  
  <p>Which is fine to turn out like</p>
  
  <p>C:\Python34\Scripts['It's fine'].jpg </p>
  
  <p>so I assume this kind of problem has something to do with the save function.  </p>
  
  <p>The trace back calls the pic.save line of code in PIL\Image.py and says the OSError: [Errno 22] is an Invalid argument in the save destination. </p>
  
  <p>Using Windows 7 if that matters.   </p>
  
  <p>Probably super-novice error, but I've been reading threads and can't figure this out--workaround would be cleaning the list of apostrophes before using it, which would be annoying but acceptable. </p>
  
  <p>Any help appreciated.</p>
  
  <p>---edited to fix double quotes as single, just mistyped when writing this post...doh.</p>