Linux command
python 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Run Python script
python [script.py]
Start interactive REPL
python
Execute code
python -c "[print('Hello')]"
Run module
python -m [module]
Start HTTP server
python -m http.server [8080]
Check syntax
python -m py_compile [script.py]
说明
python is the interpreter for the Python programming language, executing scripts or starting an interactive REPL session. It supports procedural, object-oriented, and functional programming styles, and is widely used for scripting, web development, data analysis, automation, and scientific computing. When invoked without arguments, it starts an interactive read-eval-print loop for experimentation. With a script file as argument, it compiles and executes the code. The -m flag runs installed modules as scripts, enabling built-in utilities like HTTP servers, JSON formatters, and package management through pip. On many systems, python may refer to Python 2; use python3 explicitly for Python 3.
参数
- -c _CODE_
- Execute code string.
- -m _MODULE_
- Run library module.
- -i
- Interactive after script.
- -O
- Optimize bytecode.
- -V
- Show version.
- -u
- Unbuffered output.
FAQ
What is the python command used for?
python is the interpreter for the Python programming language, executing scripts or starting an interactive REPL session. It supports procedural, object-oriented, and functional programming styles, and is widely used for scripting, web development, data analysis, automation, and scientific computing. When invoked without arguments, it starts an interactive read-eval-print loop for experimentation. With a script file as argument, it compiles and executes the code. The -m flag runs installed modules as scripts, enabling built-in utilities like HTTP servers, JSON formatters, and package management through pip. On many systems, python may refer to Python 2; use python3 explicitly for Python 3.
How do I run a basic python example?
Run `python [script.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c _CODE_ do in python?
Execute code string.