数码之家

 找回密码
 立即注册
搜索
查看: 866|回复: 3

[软件] Python报错invalid syntax

[复制链接]
发表于 2021-9-11 11:15:28 | 显示全部楼层 |阅读模式
  1. def brutal_extract(self, lengths=[4, ], lower=False, upper=False, digit=False, punctuation=False):
  2.     import string
  3.     from itertools import combinations

  4.     passward_dict = ""
  5.     if lower:
  6.         passward_dict += string.ascii_lowercase
  7.     if upper:
  8.         passward_dict += string.ascii_uppercase
  9.     if digit:
  10.         passward_dict += string.digits
  11.     if punctuation:
  12.         passward_dict += string.punctuation

  13.     print("密码本:\t()\n密码长度: \t()\n".format(passward_dict, lengths))

  14.     count = 0
  15.     for length in lengths:
  16.         for passward in combinations(passward_dict, length):
  17.             passward = "".join(passward)
  18.             count += 1
  19.             print(passward, end=" ")
  20.             if self.extract(passward):
  21.                 print()
  22.                 print("一共尝试了{}种可能".format(count))
  23.                 return
  24.         print("对不起,暂未找到,请尝试:\n1. 其他密码长度\n2. 包含更多种类的密码字符")
  25. def extract(self, passward):
  26.     try:
  27.         self.fp.extractall(path=self.tatget_path, pwd=passward.encode()
  28. <font color="#ff0000">        print()</font>
  29.         print('成功破解该压缩包,密码为: ' + passward)
  30.         self.fp.close()
  31.         return True
  32.     except:
  33.         pass
复制代码
有没有大佬帮我看看这里为什么会报错,缩进和拼写都没有问题但红色哪里就是一直报错
代码是知乎上的
 楼主| 发表于 2021-9-11 11:55:11 | 显示全部楼层
草,代码好像不能设置颜色,就是31行
回复 支持 反对

使用道具 举报

发表于 2021-9-11 15:08:28 | 显示全部楼层
sae_ 发表于 2021-9-11 11:55
草,代码好像不能设置颜色,就是31行

第30行的最右边少了一个括号:
self.fp.extractall(path=self.tatget_path, pwd=passward.encode())
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-9-11 15:45:34 | 显示全部楼层
cptw2006 发表于 2021-9-11 15:08
第30行的最右边少了一个括号:
self.fp.extractall(path=self.tatget_path, pwd=passward.encode()) ...

谢谢!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2024-4-26 11:36 , Processed in 0.171600 second(s), 11 queries , Redis On.

Powered by Discuz!

© 2006-2023 smzj.net

快速回复 返回顶部 返回列表