Python -c and -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:~$ 
strong@foreverstrong:~$ python --version
Python 2.7.12
strong@foreverstrong:~$ 

2. 查看 Python 安装路径

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

3. 查看 Numpy 版本

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

4. 查看 Numpy 安装路径

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

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值