Python: Converting to str while keeping leading 0's
<p>So in python I'm trying to access a file path in the order of 000X</p>

<p>So I start by setting a string to </p>

<pre><code>path = '0001'
</code></pre>

<p>and then point to and open the file path</p>

<pre><code>filepath = open('/home/pi/Pictures' + path + '.JPG', 'rb')
</code></pre>

<p>so I do my business and now want to access the next file of extension 0002</p>

<pre><code>intpath = int(path)
intpath = intpath + 1
path = str(intpath)
</code></pre>

<p>I'm sure this is inefficient, but I'm starting out. Unfortunately, this makes path '2' and not '0002'....any idea how I can maintain the leading zeros? </p>
