您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python FTP到iPad

5b51 2022/1/14 8:21:20 python 字数 2396 阅读 502 来源 www.jb51.cc/python

我在Windows 7上.我无法使用简单的Python脚本连接到我的iPad:HOST = '192.168.1.122' try: f = ftplib.FTP(HOST) except (socket.error, socket.gaierror), e: MessageBox.Show('ERROR: cannot reach

概述

我在Windows 7上.

我无法使用简单的Python脚本连接到我的iPad:

HOST = '192.168.1.122'
try:
    f = ftplib.FTP(HOST)
except (socket.error,socket.gaierror),e:    
    MessageBox.Show('ERROR: cannot reach "%s"' % HOST)
    return          
try:
    f.connect(HOST,2121)
    f.login()
except ftplib.error_perm:
    MessageBox.Show('ERROR: cannot login anonymously')
    f.quit()
    return

我遇到的错误是“getaddrinfo返回一个空列表”和“无法到达…”消息…无法解决它…

我尝试使用iPad上的几个程序进行FTP而没有成功.如果我通过DOS框FTP或使用FTP软件,它的工作原理.我在我的电脑上尝试了另一台FTP服务器,但它确实有效.

我被迫使用端口2121,所以不能改变它.

任何线索或经验?

class ftplib.FTP([host[,user[,
passwd[,acct[,timeout]]]]]) Return a
new instance of the FTP class. When
host is given,the method call
connect(host) is made. When user is
given,additionally the method call
login(user,passwd,acct) is made
(where passwd and acct default to the
empty string when not given). The
optional timeout parameter specifies a
timeout in seconds for blocking
operations like the connection attempt
(if is not specified,the global
default timeout setting will be used).

因此,如果你执行f = ftplib.FTP(HOST)它会失败,因为它将尝试连接到标准端口(21)而不是2121.
你应该得到一个ftplib的实例,然后使用f.connect(HOST,2121).

http://docs.python.org/library/ftplib.html

总结

以上是编程之家为你收集整理的Python FTP到iPad全部内容,希望文章能够帮你解决Python FTP到iPad所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶