[英]Python error : X() takes exactly 1 argument (8 given)
I'm trying to bulid an Anonymous FTP scanner , but i got an error about calling function X , i defined X to recieve ony 1 arguement which is the ip address , the same code works if i don't use the loop and send the IPs one by one . 我试图建立一个匿名FTP扫描程序,但我得到一个关于调用函数X的错误,我定义X接收1争论这是IP地址,相同的代码工作,如果我不使用循环并发送知识产权一个接一个。
The error is : X() takes exactly 1 argument (8 given) 错误是:X()只取1个参数(给定8个)
from ftplib import FTP
import ipcalc
from threading import Thread
def X (ip):
try:
ftp = FTP(ip)
x = ftp.login()
if 'ogged' in str(x):
print '[+] Bingo ! we got a Anonymous FTP server IP: ' +ip
except:
return
def main ():
global ip
for ip in ipcalc.Network('10.0.2.0/24'):
ip = str(ip)
t = Thread (target = X, args = ip)
t.start()
main ()
When constructing Thread
objects, args
should be a sequence of arguments, but you are passing in a string. 构造
Thread
对象时, args
应该是一个参数序列,但是你传入一个字符串。 This causes Python to iterate over the string and treat each character as an argument. 这会导致Python迭代字符串并将每个字符视为参数。
You can use a tuple containing one element: 您可以使用包含一个元素的元组:
t = Thread (target = X, args = (ip,))
or a list: 或列表:
t = Thread (target = X, args = [ip])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.