-u,-m参数有什么作用? [英] What do -u, -m parameters do?
问题描述
参数-u
,-m
的含义是什么?
例如:
python -u my_script.py
或
python -m my_script.py
我在哪里可以读到它们?
-u
用于强制stdin
,stdout
和stderr
完全不缓冲,否则将在终端上进行行缓冲>
-m
在sys.path
中搜索命名的模块,并将相应的.py文件作为脚本运行.一个示例是timeit
模块.命令python -m timeit "python script"
将返回脚本执行所花费的时间.
引用文档
强制
stdin
,stdout
和stderr
完全未缓冲.在重要的系统上,也将stdin
,stdout
和stderr
放在二进制文件中 模式.在
sys.path
中搜索命名的模块,并将其内容作为__main__
模块执行.
您可以在此处
了解更多信息What do parameters -u
, -m
mean and what do they do?
for example:
python -u my_script.py
or
python -m my_script.py
Where can I read about them?
-u
is used to force stdin
, stdout
and stderr
to be totally unbuffered, which otherwise is line buffered on the terminal
-m
searches sys.path
for the named module and runs the corresponding .py file as a script. An example would be timeit
module. The command python -m timeit "python script"
would return the time taken for the script to execute.
Quoting from the docs
Force
stdin
,stdout
andstderr
to be totally unbuffered. On systems where it matters, also putstdin
,stdout
andstderr
in binary mode.Search
sys.path
for the named module and execute its contents as the__main__
module.
You can read more about them and other options here
这篇关于-u,-m参数有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!