我尝试编写此代码,但出现错误。使用Windows 10和python 3.8.5
#usage
#python3 coex.py combo.txt extracted.txt
from sys import argv
import re
script , combo_file , ex_file = argv
cfile = open(combo_file)
xfile = open(ex_file, 'w')
def rexmail(cfile):
rexmail = re.compile(r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9.-]+:[a-zA-Z0-9._-]+')
cfile = rexmail.findall(cfile.read())
lenofclist = len(cfile)
for i in range(lenofclist):
xfile.write("\n")
xfile.write(str(cfile[i]))
print("[+]*********EXTRACTING DONE***********[+]\n")
print("[+]*********CHECK extracted.txt FILE FOR EMAIL:PASS COMBOS*************[+]\n")
def header():
print('''
made with <3
_______ ___ ___ _________ ________ ________ ________ _________ ________ ________
|\ ___ \ |\ \ / /| |\___ ___\ |\ __ \ |\ __ \ |\ ____\ |\___ ___\ |\ __ \ |\ __ \
\ \ __/| \ \ \/ / / \|___ \ \_| \ \ \|\ \ \ \ \|\ \ \ \ \___| \|___ \ \_| \ \ \|\ \ \ \ \|\ \
\ \ \_|/__ \ \ / / \ \ \ \ \ _ _\ \ \ __ \ \ \ \ \ \ \ \ \ \\\ \ \ \ _ _\
\ \ \_|\ \ / \/ \ \ \ \ \ \\ \| \ \ \ \ \ \ \ \____ \ \ \ \ \ \\\ \ \ \ \\ \|
\ \_______\ / /\ \ \ \__\ \ \__\\ _\ \ \__\ \__\ \ \_______\ \ \__\ \ \_______\ \ \__\\ _\
\|_______| /__/ /\ __\ \|__| \|__|\|__| \|__|\|__| \|_______| \|__| \|_______| \|__|\|__|
|__|/ \|__|
EMAIL:PASS extractor from any txt file .
''')
header()
rexmail(cfile)
错误:
Traceback (most recent call last):
File "C:\Users\BRS\Desktop\minecraft\Combo-Extractor-master\coex.py", line 8, in <module>
script , combo_file , ex_file = argv
ValueError: not enough values to unpack (expected 3, got 1)
我真的没有得到什么。请通过更正此代码来帮助我。并告诉我为什么会发生这种情况
元组有问题吗?请问这有什么帮助
答案 0 :(得分:2)
argv
实际上返回一个列表,其第一个元素(即索引0元素)是python文件的位置。要更正此错误,请使用
script, combo_file, ex_file = argv[1:]
另外,您也可以使用_, script, combo_file, ex_file = argv
相关文档-https://docs.python.org/3/library/sys.html
(在Windows 10(64位)Python 3.7.4上测试)