This is my code:
import base64
with open('/Users/Bob/test.txt') as f:
encoded = base64.b64encode(f.readlines())
print(encoded)
I've based it on the base64 documentation. However, when I try running it with Python 2.7.1 and Python 3.2.2 I get the error:
import base64
File "/Users/Bob/test.txt'", line 4, in <module>
encoded = base64.b64encode(f.readlines())
AttributeError: 'module' object has no attribute 'b64encode'
Why can't the b64encode attribute be found?