如何在双绞线python中在同一条线上发送和接收数据?

How to send and receive data on the same line in twisted python?

我正在使用扭曲 python 模拟 SFTP 服务器。 我想在从同一行的用户那里获得输入之前发送“ftp>”。 我试过了

basic.LineOnlyReceiver.sendLine(self, msg)

但它在另一行获取输入 怎么做到如图的样子?

我要模拟的输出示例 ftp> 用户写的任何命令都应该在同一行 ftp>密码

我们覆盖的内部回复方法,根据您想要的输出使用其中之一

 def reply(self, key):
          
     self.sendLine(msg) # if you want to send data on separate lines
     self.transport.write(b'ftp> ') # if you want to send data without'/n' delimiter