util.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:observations 作者: edwardlib 项目源码 文件源码
def hashes_match(path, hash_true, algorithm='md5'):
  """Check whether the computed hash from the file matches the
  specified hash string.

  Args:
    path: str.
      Full path to a file.
    hash_true: str.
      True hash of the file.
    algorithm: str, optional.
      Name of hashing algorithm. See `hashlib.algorithms_available`
      for list of available hashing algorithms in python.

  Returns:
    bool. True if the hashes match, else False.

  #### Examples

  ```python
  hashes_match('train.gz', '5503d900f6902c61682e6b6f408202cb')
  ## True

""" if os.path.exists(path): return get_file_hash(path, algorithm) == hash_true else: return False ```

评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号