在Windows操作系统中,你可以通过以下几种方法在命令提示符(cmd)中查看Python的安装路径:
1. 使用 `where python` 命令:
where python
这个命令会显示Python可执行文件的路径。
2. 使用 `python -c "import sys; print(sys.executable)"` 命令:
python -c "import sys; print(sys.executable)"
这行代码会在Python交互式解释器中执行,并打印出Python解释器的路径。
3. 查看 `sys.path` 变量:
python -c "import sys; print(sys.path)"
在Python交互式解释器中运行上述命令,`sys.path` 列表中的第一个元素通常就是Python的安装路径。
请选择适合你的方法来查看Python的安装路径