python获得linux下所有挂载点(mount points)的方法

yipeiwu_com5年前Python基础

本文实例讲述了python获得linux下所有挂载点(mount points)的方法。分享给大家供大家参考。具体实现方法如下:

# execute the external "mount" command
# and parse the output.
import commands
mount = commands.getoutput('mount -v')
lines = mount.split('\n')
points = map(lambda line: line.split()[2], lines)
print points

希望本文所述对大家的Python程序设计有所帮助。

相关文章

python基于Tkinter库实现简单文本编辑器实例

本文实例讲述了python基于Tkinter库实现简单文本编辑器的方法。分享给大家供大家参考。具体实现方法如下: ## {{{ http://code.activestate.com...

Python:type、object、class与内置类型实例

Python:type、object、class Python: 一切为对象 >>> a = 1 >>> type(a) <class'in...

python3 字符串/列表/元组(str/list/tuple)相互转换方法及join()函数的使用

在抓取网络数据的时候,有时会用正则对结构化的数据进行提取,比如 href="https://www.1234.com"等。python的re模块的findall()函数会返回一个所有匹配...

用Python将一个列表分割成小列表的实例讲解

用Python将一个列表分割成小列表的实例讲解

方法一 def list_of_groups(init_list, childern_list_len): ''' init_list为初始化的列表,childern_list_...

Python选择排序、冒泡排序、合并排序代码实例

前两天刚装了python 3.1.1, 禁不住技痒写点code。 1.选择排序 复制代码 代码如下: >>> def SelSort(L):   &...