Python ValueError:没有足够的值来解包(预期值为3,实际值为1)

2024-10-01 22:38:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试编写此代码,但出现了一个错误。使用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)

我真的不知道该怎么办。请帮我更正这个代码。如果可能的话,告诉我为什么会这样

这是元组的问题还是请帮助解决


Tags: 代码pytxt错误exfileprintcombo
1条回答
网友
1楼 · 发布于 2024-10-01 22:38:47

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上测试)

相关问题 更多 >

    热门问题