# import re # from Base.Class.Encrypt import * # # def _sub_variable(text, vars_dict): # if not isinstance(text, str): # return text # for variable_name in re.findall('\${(.*?)}', text): # try: # value = vars_dict[variable_name] # except Exception: # value = '' # if value is None: # value = '' # text = text.replace('${%s}' % variable_name, str(value)) # return text # # def _sub_encry(text, encr_dict): # if not isinstance(text, str): # return text # for encr_text in re.findall('\$([0-9a-zA-Z_]+)\((.*?)\)', text): # try: # value = encr_dict[encr_text[0]](encr_text[1]) # except Exception: # value = '' # if value is None: # value = '' # text = text.replace('$%s(%s)' % (encr_text[0], encr_text[1]), str(value)) # return text # # # print(_sub_variable(text='name=${name}', vars_dict={'name': '赵亚凡163'})) # print(_sub_encry(text='name=$md5(赵亚凡163)', encr_dict={'md5': md5})) # def read_encoding(path): # import chardet # return chardet.detect(open(path, 'rb').read(4096))['encoding'] # # print(read_encoding('D:\\Desktop\\1.csv')) print({'是': True, '否': False}['是'])