import urllib2
url = 'http://cidian.youdao.com/download/YoudaoDict.exe'
usock = urllib2.urlopen(url)
lastModified = usock.info().get('Last-Modified') #last modified time
#补充一下,这个是此网页的修改时间,即此文件的最后上传时间
size = usock.info().get('Content-Length')
if size is None:
size = 0
size = float(size) # in bytes
sizeK = size / 1024.0 # in KB (Kilo Bytes)
sizeM = sizeK / 1024.0 # in MB (Mega Bytes)
print "Last Modified: ",lastModified
print "Size: %.0f bytes"%size
print "Size: %.3f KB"%sizeK
print "Size: %.3f MB"%sizeM
fileName = url.split('/')[-1]
print "Filename: %s"%fileName
python获取网络文件信息
最新推荐文章于 2024-07-18 02:22:28 发布