我正在读Python ^{
Test modules can be specified by file path as well:
python -m unittest tests/test_something.py
This allows you to use the shell filename completion to specify the test module. The file specified must still be importable as a module. The path is converted to a module name by removing the
.py
and converting path separators into.
. If you want to execute a test file that isn’t importable as a module you should execute the file directly instead.
我知道*.py
文件是一个模块。那么,以下内容的含义是什么:
The file specified must still be importable as a module.
在Python中定义模块实际上有三种不同的方法:
collections
模块一样李>在这三种情况下,访问模块内容的方式相同:使用import语句
要构建一个模块并使其可导入,只需创建一个包含合法Python代码的文件,然后为该文件指定一个扩展名为
.py
的名称。就这样没有特殊的语法或巫毒是必要的
您可以在Python's official docs.中找到有关模块的更多信息
相关问题 更多 >
编程相关推荐