-1
我遇到__import__
方法的問題。它似乎只導入模塊的基本目錄,而不是文件。__import__只能導入__init__.py
比如我有:
test_suite/assert_array_length.py
當我通過這個到__import__
:
moduleLocation = "test_suite.assert_array_length"
module = __import__(moduleLocation)
print module
我越來越:
[sub_directories]/test_suite/__init__.pyc
調用序列會從run_tests.py
到test_runner.py
。 test_runner.py
然後進口assert_array_length.py
。他們制定了這樣的:
run_tests.py
|-----------test_runner.py
|-----------assert_array_length.py
,因爲它導入__init__.py
,我不能讓我從assert_array_length.py
文件需要。
非常感謝。這工作完美。 –