是否可以在python中使用一行命令来执行简单的ftp服务器?我希望能够以快速和临时的方式将文件传输到Linux机器而无需安装ftp服务器.最好是使用内置python库的方式,这样就没有什么额外的安装了.
我正在通过学习Twisted工作,偶然发现了一些我不太确定我非常喜欢的东西 - "Twisted Command Prompt".我正在摆弄我的Windows机器上的Twisted,并尝试运行"聊天"示例:
from twisted.protocols import basic
class MyChat(basic.LineReceiver):
    def connectionMade(self):
        print "Got new client!"
        self.factory.clients.append(self)
    def connectionLost(self, reason):
        print "Lost a client!"
        self.factory.clients.remove(self)
    def lineReceived(self, line):
        print "received", repr(line)
        for c in self.factory.clients:
            c.message(line)
    def message(self, message):
        self.transport.write(message + '\n')
from twisted.internet import protocol
from twisted.application import service, internet
factory = protocol.ServerFactory()
factory.protocol = MyChat
factory.clients = []
application = service.Application("chatserver")
internet.TCPServer(1025, factory).setServiceParent(application)
但是,要将此应用程序作为Twisted服务器运行,我必须通过"Twisted命令提示符"运行它,并使用以下命令:
twistd -y chatserver.py
有没有办法更改代码(设置Twisted配置设置等),以便我可以通过以下方式运行它:
python chatserver.py
我用谷歌搜索,但搜索条件似乎太模糊,无法返回任何有意义的回复.
谢谢.