如何将线程参数中的IP地址作为一个参数传递?

问题描述 投票:0回答:1

[我正在编写一个使用线程模块使用线程扫描网络的侦查工具,但是线程给我一个类型错误,并告诉我线程arg节中的每个字符都是单个参数

 for host in nm.all_host():
        threadx = threading.Thread(target=some_function, args=(host))
        thread_list.appened(threadx)
        thread.start()

TypeError:some_function()恰好接受1个参数(给定11个)给定的11表示网关地址,它包含11个字符,包括“。”。给定的13是指具有13个字符的客户地址,包括“。”

python arguments ip nmap
1个回答
1
投票

您正在传递字符串而不是元组,要传递元组,您应该在主机之后添加一个逗号,如下所示:

threadx = threading.Thread(target=some_function, args=(host,))
© www.soinside.com 2019 - 2024. All rights reserved.