如何将Python安装目录打印到输出? [英] How to print Python installation directory to the output?
本文介绍了如何将Python安装目录打印到输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设Python安装在该位置
Let's say Python is installed in the location
C:\ TOOLS \ COMMON \ python \ python252
C:\TOOLS\COMMON\python\python252
我想在程序输出中打印此位置.请让我知道我可以这样做.
I want to print this location in the output of my program. Please let me know can I do this.
推荐答案
您可以使用
import sys, os
os.path.dirname(sys.executable)
但是请记住,在Unix系统中,程序的安装"通常是沿着以下文件夹分布的:
but remember than in Unix systems the "installation" of a program is usually distributed along the following folders:
- /usr/bin(您可能会得到的)
- /usr/lib
- /usr/share
- 等
这篇关于如何将Python安装目录打印到输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文