小编Say*_*Deo的帖子

UnetSocket send() 返回一个 Nonetype 对象

我正在尝试 UnetStack 手册中指定的 python 代码。在运行tx.py和rx.py 时,当我在终端上打印时成功创建了 UnetSocket 对象,但 send() 函数在接收器处发送 Nonetype 数据。

tx.py ===>>

from unetpy import UnetSocket

s = UnetSocket('localhost',1101)
print(s)
s.send('hellooo',31)
s.close()
Run Code Online (Sandbox Code Playgroud)

rx.py ====== >>>

from unetpy import UnetSocket
s = UnetSocket('localhost',1102)
rx = s.receive()
print('here ',rx)
print('from node : ',bytearray(rx.data).decode())
s.close()
Run Code Online (Sandbox Code Playgroud)

首先,我在模拟器上运行 2-node-network.groovy。然后从终端 rx.py 和下一个 tx.py。

rx.py 回溯错误(最近一次调用):文件“rx.py”,第 6 行,在

print('from node : ',bytearray(rx.data).decode())

AttributeError: 'NoneType' object has no attribute 'data'
Run Code Online (Sandbox Code Playgroud)

O/p at tx.py <unetpy.UnetSocket object at 0x7fe2909d4550>

python sockets groovy send unetstack

4
推荐指数
1
解决办法
89
查看次数

标签 统计

groovy ×1

python ×1

send ×1

sockets ×1

unetstack ×1