在python的源代码中:usr/local/lib/python3.3/unittest/__init__.py
from .result import TestResult
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
skipUnless, expectedFailure)
from .suite import BaseTestSuite, TestSuite
from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
findTestCases)
from .main import TestProgram, main
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler
我无法理解 .result
和 .main
。为什么它们的名称中有一个点前缀?
最佳答案
它叫做 relative import .
这意味着您从与此代码所在的模块相同的目录中的模块导入。如果没有点,它将从 PYTHON PATH 中找到的第一个模块导入。
关于python - ".main"在python源代码中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19785485/