这是我的代码:
import base64
with open('/Users/Bob/test.txt') as f:
encoded = base64.b64encode(f.readlines())
print(encoded)
我已经根据它Base64 文档 http://docs.python.org/library/base64.html。但是,当我尝试使用 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
属性找到了吗?
你有一个名为base64.py
它正在隐藏 stdlib 模块。重命名它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)