使用Python的-m标志运行模块 | AI生成和翻译

Home 2025.09

是的,-m 表示将模块作为脚本运行。让我们通过示例来详细说明:

python -m unittest

这个指令告诉 Python:

python -m pip

这是同样的模式:

python test_xx.py 的区别

当你执行:

python test_xx.py

你是在直接运行特定文件,而不是使用 unittest 的测试发现机制或运行器


总结

需要我进一步说明 pytest 的不同处理方式吗?这样你可以对比 unittestpytest 的差异?


Back

openai/gpt-5

Donate