用python写一个含有敏感信息的文档自动加密的软件,步骤如下:首先弹窗自己选择某个文件夹或某个盘,然后查找其中存在的word和excel文档,检索文档中是否存在身份证号码、电话号码、银行卡号码这三种敏感信息,超过5条的,判定为敏感文件,然后弹出一个密码输入框,输入自己想要的密码,使用这个密码对刚刚选择的那个文件里面的所有含有敏感信息的文档进行加密
艺术品 | 重量 | 价值 |
---|---|---|
1 | 2 | 3 |
2 | 3 | 4 |
3 | 4 | 8 |
4 | 5 | 8 |
5 | 9 | 10 |
def dpMaxValue(objectsValueDic, weights, maxValue, objectsUsed):
for weight in range(weights + 1):
nowValue = objectsValueDic[0]
newWeight = 0
for j in [c for c in objectsValueDic.keys() if c <= weight]:
if maxValue[weight - j] + objectsValueDic[j] > nowValue:
nowValue = maxValue[weight - j] + objectsValueDic[j]
newWeight = j
maxValue[weight] = nowValue
objectsUsed[weight] = newWeight
return maxValue[weights]
def printWeight(objectsUsed, weights):
weight = weights
out = []
while weight > 0:
thisWeight = objectsUsed[weight]
if thisWeight == 0:
break
out.append(thisWeight)
weight -= thisWeight
print('weights:',out)
if __name__ == '__main__':
objectsValueDic = {0 : 0, 2 : 3, 3 : 4, 4 : 8, 5 : 8, 9 : 10}
weights = 20
objectsUsed = [0] * (weights+1)
print('value :',dpMaxValue(objectsValueDic, weights, [0] * (weights+1), objectsUsed))
printWeight(objectsUsed, weights)