查看 python 的版本 以及 python 的安装位置路径
python的版本
import sys
print(sys.version)
3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
import subprocess
command = "python -V"
open_process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
shell=True
)
cmd_out = open_process.stdout.read()
open_process.stdout.close()
print("输出:", cmd_out.decode(encoding="gbk"))
输出: Python 3.8.10
python的位置
command = "where python"
open_process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
shell=True
)
cmd_out = open_process.stdout.read()
open_process.stdout.close()
print("输出:", cmd_out.decode(encoding="gbk"))
输出: C:\Python38\python.exe
C:\Users\xiahuadong\AppData\Local\Microsoft\WindowsApps\python.exe
|