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

What do -u, -m parameters do?

参数 -u-m 是什么意思,它们有什么作用?

例如:

python -u my_script.py 

python -m my_script.py

我在哪里可以读到它们?

-u 用于强制 stdinstdoutstderr 完全无缓冲,否则在终端

上行缓冲

-m 搜索 sys.path 命名模块并运行相应的 .py 文件作为脚本。一个例子是 timeit 模块。命令 python -m timeit "python script" 将 return 脚本执行所花费的时间。

引用文档

-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.

您可以阅读有关它们和其他选项的更多信息here