Python Can';t转换为';元组';对象隐式地访问str

Python Can';t转换为';元组';对象隐式地访问str,python,udpclient,Python,Udpclient,我是Python新手,在用Python创建客户机-服务器UDP-ping服务器程序时遇到了这个严重错误。它说: TpyeError: Can't convert 'tuple' object to str implicitly UDPClient.py文件中存在错误,该文件为: from socket import * from datetime import * from time import * pings = 10 i =0 server = '127.0.0.1' servPo

我是Python新手,在用Python创建客户机-服务器UDP-ping服务器程序时遇到了这个严重错误。它说:

TpyeError: Can't convert 'tuple' object to str implicitly 
UDPClient.py文件中存在错误,该文件为:

from socket import *
from datetime import *
from time import *

pings = 10
i =0 
server = '127.0.0.1'
servPort = 5369
clientSock = socket(AF_INET, SOCK_DGRAM)
data = 'ping'
databin = bytes(data, 'UTF-8')
while i<pings:
    print("Print number: ",i)
    i += 1
    before = datetime.now()
    clientSock.sendto(databin, (server, servPort) )
    clientSock.settimeout(1)

    try:
       clientMsgm server = cliendSock.recvfrom(1024)
       after = datetime.now()
       diff = before - after
       if(i==10):
            print("Ping", i)

   except timeout:
       print("Ping",i," Request timed out!!!")


Traceback (most recent call last):

File "D:\...\UDPClient.py", line 18, in <module>
clientSock.sendto(databin,server, servPort ) # Send what (i.e.'ping') and to whom and where
TypeError: an integer is required (got type str)
从套接字导入*
从日期时间导入*
不定期进口*
pings=10
i=0
服务器='127.0.0.1'
servPort=5369
clientSock=socket(AF_INET,SOCK_DGRAM)
数据='ping'
databin=字节(数据“UTF-8”)

而i此错误是由于试图以不受支持的方式组合
str
tuple
而导致的

例如:

Python 3.3.2+(默认,2014年2月28日00:52:16)
[GCC 4.8.1]在linux上
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>“foo”+(“bar”)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
TypeError:无法将“tuple”对象隐式转换为str

我不认为您包含的代码示例正在执行此操作,但是

哪一行给出了错误?您在分配
数据输入时是否遗漏了“t”
?请发布完整的回溯,还有,您使用的是哪种python版本?我想错误一定在
是之前
请始终复制并粘贴成绩单,而不是将其打印出来。
TpyeError
中的输入错误使人很难知道
yes
中的输入是否有意义。我该怎么办?因为正常运行4 ping它工作正常,但它显示了错误!
Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> "foo" + ("bar",)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't convert 'tuple' object to str implicitly