这是我的代码:
import base64
with open('/Users/Bob/test.txt') as f:
encoded = base64.b64encode(f.readlines())
print(encoded)
我把它建立在base64 documentation上。然而,当我尝试用Python 2.7.1和Python 3.2.2运行它时,我得到了错误:
import base64
File "/Users/Bob/test.txt'", line 4, in <module>
encoded = base64.b64encode(f.readlines())
AttributeError: 'module' object has no attribute 'b64encode'
为什么找不到b64encode
属性?
发布于 2012-08-19 01:50:47
您有一个名为base64.py
的脚本,它跟踪stdlib模块。将其重命名。
https://stackoverflow.com/questions/12020885
复制相似问题