我收到了以下错误,我不知道发生了什么。有任何想法吗?感谢
python -m SimpleHTTPServer
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleHTTPServer.py", line 16, in <module>
import urllib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 30, in <module>
import base64
File "base64.py", line 7, in <module>
print (base64.b64decode(cookie))
AttributeError: 'module' object has no attribute 'b64decode'
答案 0 :(得分:0)
您似乎拥有名为base64.py
的文件的本地副本。以下是错误输出的最后几行:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 30, in <module>
import base64
File "base64.py", line 7, in <module>
print (base64.b64decode(cookie))
AttributeError: 'module' object has no attribute 'b64decode'
请注意这两个文件名。 urllib.py
有一条进入python库的完整路径。 base64.py
没有路径,因此在当前目录中(即,可能是您的项目目录)。
因此,您需要将文件重命名为base64.py