【问题标题】:split large .lst file into pieces because because readlines() cant read the full file将大型 .lst 文件拆分为多个部分,因为 readlines() 无法读取完整文件
【发布时间】:2017-08-29 15:52:14
【问题描述】:

为了使用单词表(大的“16 Gb”)来破解密码问题,我下载了一个 .lst 格式的文件,来自:https://crackstation.net/buy-crackstation-wordlist-password-cracking-dictionary.htm

因此,当我尝试 readlines() 文件以拆分行时,它仅读取 69100 行,即使 worlist 包含超过 10 亿行。

例如:

passwordlist = str(raw_input("\nEnter the path name of the password list file : "))
list = open(passwordlist, "r")
passwords = list.readlines()
list.close()
for password in  passwords:
        attack(password.replace("\n",""))

我需要使用 python 将文件拆分为 txt 片段,而无需读取诸如拆分视频或音频之类的行。

有什么可以帮忙的。

【问题讨论】:

标签: python


【解决方案1】:

您是否尝试过循环读取?读取(大小)或读取线() https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects

【讨论】:

  • 是的!谢谢你的提醒。如果你能提供帮助,那就是代码:justpaste.it/edit/15414193/a5a3d8c5
  • 问题出在“密码”变量上。而不是 list.readlines() 使用 readlines() 循环文件对象并检查当前行。 (或者对数据块使用 read(size)。)
  • 我已经尝试过这个:justpaste.it/edit/15414472/f0e084a6,当我打印块时,它会不断重复第一个块。
  • 实际上 readlines 可以读取超过 69100 行,因为我用另一个单词列表尝试过它并且它已经读取了超过一百万行但是在这个单词列表中它在达到 69100 行时停止,即使单词列表包含超过 10 亿行。
猜你喜欢
  • 2010-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多