0
Python預裝在我的macbook上,我一直在慢慢熟悉這個語言。但是,似乎我的配置是不正確的,或者我只是誤解了某些東西,而且事情是不對的。每當我運行帶有「import re」的python腳本,我會收到以下錯誤:是在MacBook上重新錯誤的默認配置?或者我只是誤解了一些東西?
Traceback (most recent call last):
File "regex.py", line 2, in <module>
import re
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py", line 4, in <module>
# re-compatible interface for the sre matching engine
AttributeError: 'module' object has no attribute 'compile'
什麼給!
嘿,感謝您的深入評論!我已經嘗試了以上,並得到了一個錯誤,我想我會得到。 re._file_應該是某種文件,不是?按照原樣輸入文件「」,第1行,在 AttributeError:'module'object has no attribute'_file_' –
Chris
2009-08-08 17:58:10
@Chris,_ouch_ - 我不知道你的機器如何變得如此混亂,我衷心推薦您從DVD重新安裝Leopard(請記得在獲得安全修補程序後立即進行軟件升級!)。如果您有可用的磁盤空間和可能值得保留的東西,我建議「歸檔並安裝」選擇安裝,但將其他地方明確保存,並選擇從頭開始重新安裝的選項也是一種吸引人的可能性。 – 2009-08-08 18:41:21
Chris,你需要在'file'前後使用* two *下劃線來遵循Alex的指示。你能用'__file__'而不是'_file_'重新發布結果嗎? – 2009-08-08 19:18:53