Read certain part of string from file
<p>Trying python after a very long time now.</p>

<p>I have a file that has a line:</p>

<pre><code>My_NUMBER                 =  24
</code></pre>

<p>I want to extract this number ( here I have assumed 24 but this is something I want to extract based on My_NUMBER.In my python code I am able to read the line </p>

<pre><code>with open(filename) as f: lines = f.read().splitlines()

for line in lines:
    if line.startswith(' My_NUMBER                 ='):
        line=(line.rsplit(' ', 1)[0])
        num= line.rsplit('=',1)[1].split("=")[0]
        num = num.strip(" ")
        print num
</code></pre>

<p>However this does print blank output and not the number. Can anyone commet in case I am doing anything obviously wrong here?</p>
