1
這裏不工作的Python標準庫是re.py
內容:內的virtualenv
import re
if re.search('test', 'test'): print 'match'
當我運行$ python re.py
,輸出,很明顯,是match
。但是,當我激活的virtualenv並嘗試再次運行該腳本,我得到:
...
if re.search('test', 'test'): print 'match'
AttributeError: 'module' object has no attribute 'search'
這裏是Python解釋器的輸出時的virtualenv未激活:
$ python
Python 2.7.5 (default, Jun 3 2013, 17:42:22)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin
而這裏的輸出時這是積極的:
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
爲什麼使用Python 2.7.5當re
模塊斷裂的virtualenv裏面?
工作 - 謝謝。但爲什麼virtualenv很重要? – 2014-11-04 05:00:28
我必須檢查,但絕對不要將文件名稱作爲python內置模塊。 – Nilesh 2014-11-04 05:03:45