Getting file size in Python

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

   This question already has an answer here:
    * /questions/2104080/how-to-check-file-size-in-python /questions/2104080/how-to-check-file-size-in-python 6 answers

Answers

http://docs.python.org/library/os.path.html#os.path.getsize http://docs.python.org/library/os.path.html#os.path.getsize

os.path.getsize(path) Return the size, in bytes, of path. Raise os.error if the file does not exist or is inaccessible.
import os
os.path.getsize( C:\Python27\Lib\genericpath.py )

OR

os.stat( C:\Python27\Lib\genericpath.py ).st_size 

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/6591931/getting-file-size-in-python

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils