zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python网页爬虫代码_python md5加密解密

2023-06-13 09:15:01 时间

大家好,又见面了,我是你们的朋友全栈君。

#!/usr/bin/env python

import os,sys,subprocess

def update(path):

f = open(file,’w’)

for root,dirs,files in os.walk(path):

for name in files:

line = os.path.join(root, name)

(stdin,stderr) = subprocess.Popen([‘md5sum’,line],stdout=subprocess.PIPE).communicate()

f.write(stdin)

f.close()

def check(path):

f = open(file,’r’)

for line in f:

check_ok = “””echo ‘%s’ | md5sum -c > /dev/null 2>&1″”” % line

#print check_ok

if not subprocess.call(check_ok, shell = True) == 0:

abnormal = line.split()

print abnormal[1]

f.close()

def Usage():

print ”’

Usage: python %s update /home/wwwroot

python %s check /home/wwwroot

”’ % (sys.argv[0],sys.argv[0])

sys.exit()

if len(sys.argv) != 3:

Usage()

file = ‘file.key’

model = sys.argv[1]

path = sys.argv[2]

if os.path.exists(path) == False:

print “\033[;31mThe directory or file does not exist\033[0m”

sys.exit()

elif model == ‘update’:

update(path)

elif model == ‘check’:

check(path)

else:

Usage()

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/187672.html原文链接:https://javaforall.cn