python sendline_sendLine不会发送整数(Twisted Python)

我正在使用Twisted库在Python中编写MUD.我目前正在尝试通过sendLine方法将整数发送到LineReceiver模块.但是,每当我尝试发送一个整数时,我在运行程序时会收到以下错误消息:

Unhandled Error

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\twisted\python\log.py", line 84, in

thLogger

return callWithContext({"system": lp}, func, *args, **kw)

File "C:\Python27\lib\site-packages\twisted\python\log.py", line 69, in

thContext

return context.call({ILogContext: newCtx}, func, *args, **kw)

File "C:\Python27\lib\site-packages\twisted\python\context.py", line 118

allWithContext

return self.currentContext().callWithContext(ctx, func, *args, **kw)

File "C:\Python27\lib\site-packages\twisted\python\context.py", line 81,

llWithContext

return func(*args,**kw)

--- ---

File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py",

46, in _doReadOrWrite

why = getattr(selectable, method)()

File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 460,

ead

rval = self.protocol.dataReceived(data)

File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 56

dataReceived

why = self.lineReceived(line)

File "server.py", line 37, in lineReceived

self.sendLine(level)

File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 62

sendLine

return self.transport.write(line + self.delimiter)

exceptions.TypeError: unsupported operand type(s) for +: 'int' and 'str'

导致错误的行是:

self.sendLine(SomeVarWhichIsANumber)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值