2016-05-12 23 views
0

我測試腳本(wcrawler.py):multiles .py在同一目錄下會影響python命令嗎?

import requests 

,並得到錯誤:

... 
File "/usr/lib/python2.7/ssl.py", line 90, in <module> 
     import textwrap 
     File "/usr/lib/python2.7/textwrap.py", line 40, in <module> 
     class TextWrapper: 
     File "/usr/lib/python2.7/textwrap.py", line 82, in TextWrapper 
     whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace)) 
    AttributeError: 'module' object has no attribute 'maketrans' 

所以我剛換了別人腳本到另一個目錄,並使用相同的命令:蟒蛇wcrawler。 py

值得,我不知道爲什麼,你知道這件事嗎?

+0

是腳本中的* only *行嗎?另外,請發佈追蹤的**全文**。 – MattDMo

+0

你最有可能在你的路徑的某個地方有一個名爲string.py的腳本,其中的textwrap是從中導入的,而不是實際的字符串庫 –

回答

0

您很有可能有一個在你的路徑 命名string.py某處腳本textwrap是從,而不是實際的字符串LIB進口 - 帕德里克·坎寧安

是正義的!

相關問題