Python: TypeError: argument after * must be a sequence

前端 未结 1 1266
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 12:02

I have this piece of code in which I try to send an UDP datagram in a new thread

import threading, socket

address = (\"localhost\", 9999)


def send(sock):
             


        
相关标签:
1条回答
  • 2021-02-08 12:29

    You need to add a comma - , - after your variable s. Sending just s to args=() is trying to unpack a number of arguments instead of sending just that single arguement.

    So you'd have threading.Thread(target=send, args=(s,)).start()

    Also the splat - * - operator might be useful in this question explaining it's usage and unzipping arguments in general

    0 讨论(0)
提交回复
热议问题