从Python查找系统硬盘驱动器? [英] Find System Hard Disk Drive from Python?

查看:154
本文介绍了从Python查找系统硬盘驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为当前应用程序开发软件安装程序。需要将其安装到系统硬盘上。我应该如何检测系统驱动器并返回来自Python的字母?



win32扩展会有用吗?用Python预先打包的os模块怎么样?

I am working on a software installer for my current application. It needs to be installed to the System HDD. How owuld I detect the system drive and return the letter from Python?

Would the win32 extensions be useful? How about the os module pre packaged with Python?

推荐答案

这是如何在上返回系统驱动器的盘符一个Win32平台:

import os
print os.getenv("SystemDrive")

以上代码段返回系统驱动器号。就我而言(大多数情况下是在Windows上)C:

The above snippet returns the system drive letter. In my case ( and most cases on windows) C:

这篇关于从Python查找系统硬盘驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆