How to create a file in a folder
<p>How can i create a <code>.pck</code> file in a folder in Python?
The name of the folder is example
I tried:</p>

<pre><code>file = open("\example\file.pck","wb")
</code></pre>

<p>But it says: </p>

<blockquote>
  <p>OSError: [Errno 22] Invalid argument: '\example\x0cile.pck'</p>
</blockquote>

<p>EDIT:
Solved! The right command is:<code>
file = open("example/file.pck", "wb")</code></p>

<p>Use forward slashes</p>

<pre><code>open("/example/file.pck", "wb")
</code></pre>

<p>Your problem is likely that backslashes were being interpreted as <a href="https://docs.python.org/2/reference/lexical_analysis.html#string-literals" rel="nofollow">escape sequences</a>.  </p>

python