Windows下Python获取磁盘空闲空间并写入日志
2018-07-20 来源:open-open
from ctypes import * import time import win32file run = True logfile = open('.\\log.out','w+');#open log file input = raw_input("Input a string for disk name like \'d:\' or other:")#input a disk name while run: sectorsPerCluster, bytesPerSector, numFreeClusters, totalNumClusters = \ win32file.GetDiskFreeSpace(input) freespace = (numFreeClusters * sectorsPerCluster * bytesPerSector) /(1024 * 1024)#get free space logfile.write("%s %s FreeSpace is %d MBytes\n" % (time.asctime(),input,freespace));#write log print time.asctime(),input,"FreeSpace is",freespace,"MBytes"#output to screen time.sleep(3)#wait 3 second logfile.close();#close log file
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐