[Python如何在没有CMD'echo%SystemRoot%'的情况下获取%SystemRoot%? [关闭]

问题描述 投票:-1回答:1

Python如何在不参考CMD命令echo %SystemRoot%的情况下找到Windows系统根目录?

python windows cmd system root
1个回答
1
投票
使用Python os模块。

# Get environment variables sr = os.getenv('SystemRoot') sr = os.environ.get('SystemRoot')

© www.soinside.com 2019 - 2024. All rights reserved.