
import time
import hashlib
filtpath=test.txt"
#转md5
def do_md5line(row):
with open(filtpath[0:-4] + "_md5.txt","a") as file_handle:
_value=row[3]
m=hashlib.md5(_value.encode())#变成bytes类型才能加密
str_md5=m.hexdigest()
file_handle.write(str_md5)
file_handle.write("
")
with open(filtpath, "r") as f:
print(time.strftime("%Y-%m-%d %H:%M:%S") + " 开始..." + filtpath)
line_num = 0
for row in f.readlines():
row = row.strip("
") #去掉换行符
print(row)
line_num += 1
#do_md5line(row)
if (line_num != 1): # 第一行标题头去掉
do_md5line(row)
print(line_num)
print(time.strftime("%Y-%m-%d %H:%M:%S") + " 结束..." + filtpath)
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 »
pyhton3 读TXT值MD5加密