您的位置:首页 > 编程语言 > Python开发

Python 获取磁盘信息的脚本及常用文件操作等

2016-07-31 13:58 736 查看
文件是否存在

os.path.exists(save_to_path+ '/0.png'):


删除

os.remove(save_to_path + '/0.png')


当前运行的脚本位置

run_path = os.path.split(os.path.realpath(__file__))[0]


获取磁盘信息

#!/usr/bin/env python
import subprocess

#Command 1
def uname_func():
uname="uname"
uname_arg="-a"
print "Gathering system information with %s command:\n" % uname
subprocess.call([uname,uname_arg])

#command 2
def disk_func():
diskspace = "df"
diskspace_arg="-h"
print "Gathering diskspace information %s command:\n" % diskspace
subprocess.call([diskspace,diskspace_arg])

def main():
uname_func()
disk_func()

main()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: