# eval用法 from hashlib import*# added for clarificationdefget_hash(self):if self.hash_type in['md5','sha1','sha224','sha256','sha384','sha512']:
data =eval(self.hash_type)# <--- how can I replace this?# 替代较为安全写法import hashlib
if self.hash_type in['md5','sha1','sha224','sha256','sha384','sha512']:
func =getattr(hashlib, self.hash_type)