Python: Converting file to base64 encoding
<p>This is my code:</p>

<pre><code>import base64

with open('/Users/Bob/test.txt') as f:
    encoded = base64.b64encode(f.readlines())
    print(encoded)
</code></pre>

<p>I've based it on the <a href="http://docs.python.org/library/base64.html" rel="nofollow">base64 documentation</a>. However, when I try running it with Python 2.7.1 and Python 3.2.2 I get the error:</p>

<pre><code>    import base64
  File "/Users/Bob/test.txt'", line 4, in &lt;module&gt;
    encoded = base64.b64encode(f.readlines())
AttributeError: 'module' object has no attribute 'b64encode'
</code></pre>

<p>Why can't the <code>b64encode</code> attribute be found?</p>
