Python -c / -m 执行命令

Python -c / -m 执行命令

1. python - an interpreted, interactive, object-oriented programming language

Python’s basic power can be extended with your own modules written in C or C++. On most systems such modules may be dynamically loaded. Python is also adaptable as an extension language for existing applications. See the internal documentation for hints.
Python 的基本功能可以使用您自己的用 C 或 C++ 编写的模块进行扩展。在大多数系统上,这些模块可以动态加载。Python 也可以作为现有应用程序的扩展语言。有关提示,请参阅内部文档。

Documentation for installed Python modules and packages can be viewed by running the pydoc program.

hint [hɪnt]:n.	暗示,线索,迹象,提示,注意事项, 微量 vt. 暗示,vi. 暗示,提示

-c command
Specify the command to execute. This terminates the option list (following options are passed as arguments to the command).
指定要执行的命令。这将终止选项列表 (紧跟的选项作为参数传递给命令)。

-m module-name
Searches sys.path for the named module and runs the corresponding .py file as a script.

1. 查看 Python 版本

strong@foreverstrong:~$ python -V
Python 2.7.12
strong@foreverstrong:~$ 

2. 查看 Python 版本

strong@foreverstrong:~$ python --version
Python 2.7.12
strong@foreverstrong:~$ 

3. 查看 Python 安装路径

strong@foreverstrong:~$ python -c "import sys; print(sys.executable)"
/usr/bin/python
strong@foreverstrong:~$ 

4. 查看 Python 安装路径

strong@foreverstrong:~$ python -c "import os; print(os.sys.executable)"
/usr/bin/python
strong@foreverstrong:~$ 

5. 查看 Python 安装路径

strong@foreverstrong:~$ python -c "import os; path = os.sys.executable; folder=path[0 : path.rfind(os.sep)]; print(folder)"
/usr/bin
strong@foreverstrong:~$ 

6. 查看 Numpy 版本

strong@foreverstrong:~$ python -c "import numpy; print(numpy.version.version)"
1.11.0
strong@foreverstrong:~$ 

7. 查看 Numpy 版本

strong@foreverstrong:~$ python -c "import numpy; print(numpy.__version__)"
1.11.0
strong@foreverstrong:~$ 

8. 查看 Numpy 安装路径

strong@foreverstrong:~$ python -c "import numpy; print(numpy.__file__)"
/usr/lib/python2.7/dist-packages/numpy/__init__.pyc
strong@foreverstrong:~$

你可能感兴趣的:(Python,3.x,-,Python,2.x)