包看起來是這樣的:導入錯誤:無法導入模塊
- main.py
- HTTPQuery.py
- SmartDownload.py
我跑from SmartDownload import DownloadFile
。
from HTTPQuery import Is_ServerSupportHTTPRange
我跑from SmartDownload import DownloadFile
我好像陷入一個循環,因爲這是錯誤
:
Traceback (most recent call last):
File "C:\Scripts\mp3grabber\main.py", line 13, in <module>
import HTTPQuery
File "C:\Scripts\mp3grabber\HTTPQuery.py", line 6, in <module>
from SmartDownload import DownloadFile
File "C:\Scripts\mp3grabber\SmartDownload.py", line 3, in <module>
from HTTPQuery import Is_ServerSupportHTTPRange
ImportError: cannot import name Is_ServerSupportHTTPRange
但我必須將第二個文件的函數導入第三個文件,反之亦然。
我該怎麼辦?
我不知道你可以做一個單一的導入,以避免循環依賴問題。涼! – 2012-02-24 17:01:11