-u,-m参数有什么作用? [英] What do -u, -m parameters do?

查看:111
本文介绍了-u,-m参数有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参数-u-m的含义是什么?

例如:

python -u my_script.py 

python -m my_script.py

我在哪里可以读到它们?

解决方案

-u用于强制stdinstdoutstderr完全不缓冲,否则将在终端上进行行缓冲

-msys.path中搜索命名的模块,并将相应的.py文件作为脚本运行.一个示例是timeit模块.命令python -m timeit "python script"将返回脚本执行所花费的时间.

引用文档

-u

强制stdinstdoutstderr完全未缓冲.在重要的系统上,也将stdinstdoutstderr放在二进制文件中 模式.

-m <module-name>

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

-u

Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode.

-m <module-name>

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆