pooch.file_hash¶
-
pooch.
file_hash
(fname)[source]¶ Calculate the SHA256 hash of a given file.
Useful for checking if a file has changed or been corrupted.
- Parameters
fname (str) – The name of the file.
- Returns
hash (str) – The hash of the file.
Examples
>>> fname = "test-file-for-hash.txt" >>> with open(fname, "w") as f: ... __ = f.write("content of the file") >>> print(file_hash(fname)) 0fc74468e6a9a829f103d069aeb2bb4f8646bad58bf146bb0e3379b759ec4a00 >>> import os >>> os.remove(fname)