我刚写了一些代码:Python的 - 检查用户更改文件
hasher = hashlib.sha1()
inputFile = open(inputPath, 'r')
hasher.update(inputFile.read().encode('utf-8'))
oldHash = hasher.hexdigest()
newHash = ''
while True:
hasher.update(inputFile.read().encode('utf-8'))
newHash = hasher.hexdigest()
if newHash != oldHash:
print('xd')
oldHash = newHash
我需要快速编写SASS编译器和如何我检查,如果用户在用户file.It任何改变的作品,但只有当我添加一些文件,当我删除任何字或字符它不检测它。
你知道为什么吗?
请花费一些时间创建一个[mcve] – Idos
您不能'read()'同一个文件两次。你必须重新打开它。 –