Split and Combine Date
<p>I am trying to write a python script that will compare dates from two different pages. The format of date in one page is Oct 03 2016 whereas on other page is (10/3/2016). My goal is to compare these two dates. I was able to convert Oct to 10 but don't know how to make it 10/3/2016.</p>

<p>Use <a href="https://docs.python.org/2/library/datetime.html" rel="nofollow"><code>datetime</code></a> module to convert your string to <code>datetime</code> object and then compare both. For example:</p>

<pre><code>&gt;&gt;&gt; from datetime import datetime
&gt;&gt;&gt; date1 = datetime.strptime('Oct 03 2016', '%b %d %Y')
&gt;&gt;&gt; date2 = datetime.strptime('10/3/2016', '%m/%d/%Y')
&gt;&gt;&gt; date1 == date2
True
</code></pre>

<p>Further, you may convert this<code>datetime</code> object to your custom format using <a href="https://docs.python.org/2/library/time.html#time.strftime" rel="nofollow">datetime.strftime()</a> as:</p>

<pre><code>&gt;&gt;&gt; date1.strftime('%d * %B * %Y')
'03 * October * 2016'
</code></pre>

<p>List of all the directives usable for formatting the string are available at the <code>strftime</code> link I mentioned above.</p>

python