import os def get_file_size(file): file.seek(0, os.SEEK_END) size = file.tell() file.seek(0) return size