python 新手,请问这个问题如何解决?
代码:importsocketfromsocketimport*fromosimportpopen#获取端口号%传输类型sock_DGRAM(udp)#创建socket对...
代码:
import socket
from socket import *
from os import popen
# 获取端口号%传输类型sock_DGRAM(udp)
#创建socket对象。调用socket构造函数
NET=socket(AF_INET,SOCK_DGRAM)
# 将socket绑定(指派)到指定地址上,socket.bind(address) adress=(host,port)
host=popen('hostname').read()
print host
set_box2=8888
args=(host,set_box2)
socket.bind(args)
问题:
Traceback (most recent call last):
File "D:/Program Files (x86)/python25/net.py", line 13, in <module>
socket.bind(args)
TypeError: unbound method bind() must be called with _socketobject instance as first argument (got tuple instance instead)
>>> 展开
import socket
from socket import *
from os import popen
# 获取端口号%传输类型sock_DGRAM(udp)
#创建socket对象。调用socket构造函数
NET=socket(AF_INET,SOCK_DGRAM)
# 将socket绑定(指派)到指定地址上,socket.bind(address) adress=(host,port)
host=popen('hostname').read()
print host
set_box2=8888
args=(host,set_box2)
socket.bind(args)
问题:
Traceback (most recent call last):
File "D:/Program Files (x86)/python25/net.py", line 13, in <module>
socket.bind(args)
TypeError: unbound method bind() must be called with _socketobject instance as first argument (got tuple instance instead)
>>> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询