How to print Python installation directory to the output?

后端 未结 2 1187
南方客
南方客 2021-02-12 08:17

Let\'s say Python is installed in the location

C:\\TOOLS\\COMMON\\python\\python252


I want to print this location in the outpu

2条回答
  •  执念已碎
    2021-02-12 08:46

    you can use

    import sys, os
    os.path.dirname(sys.executable)
    

    but remember than in Unix systems the "installation" of a program is usually distributed along the following folders:

    • /usr/bin (this is what you'll probably get)
    • /usr/lib
    • /usr/share
    • etc.

提交回复
热议问题