简体   繁体   English

-u,-m参数有什么作用?

[英]What do -u, -m parameters do?

What do parameters -u , -m mean and what do they do? 参数-u-m是什么意思,它们的作用是什么?

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 -u用于强制将stdinstdoutstderr完全取消缓冲,否则将在终端上对其进行行缓冲

-m searches sys.path for the named module and runs the corresponding .py file as a script. -m sys.path中搜索指定的模块,然后将相应的.py文件作为脚本运行。 An example would be timeit module. 一个例子是timeit模块。 The command python -m timeit "python script" would return the time taken for the script to execute. 命令python -m timeit "python script"将返回脚本执行所花费的时间。

Quoting from the docs 引用文档

-u

Force stdin , stdout and stderr to be totally unbuffered. 强制stdinstdoutstderr完全没有缓冲。 On systems where it matters, also put stdin , stdout and stderr in binary mode. 在重要的系统上,还将stdinstdoutstderr置于二进制模式。

-m <module-name>

Search sys.path for the named module and execute its contents as the __main__ module. sys.path中搜索命名模块,并将其内容作为__main__模块执行。

You can read more about them and other options here 您可以在此处阅读有关它们和其他选项的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM