2017-01-15 42 views
0

我得到了以下錯誤,我不知道發生了什麼。有任何想法嗎?感謝python模塊對象上的SimpleHTTPServer錯誤沒有屬性b64decode

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' 
+1

其他的東西你在你的項目文件夾中有一個文件「base64.py」?如果這樣重命名它。 –

回答

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

相關問題