使用python传输PDF文档的方法

2024-06-07 19:30:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我想给我的教育项目增加一个功能。 该程序目前保存一个PDF文档,其中包含一组考试问题以及最终用户对这些问题的答案。我想添加一种方式,所有的客户发送他们各自的PDF文件到一个服务器(将是教师),为他们保存。 我已经查过传输的套接字,但我不确定这是否对我的问题简单。。。 任何帮助都将不胜感激。 谢谢


Tags: 文件项目答案文档程序功能服务器客户
1条回答
网友
1楼 · 发布于 2024-06-07 19:30:54

既然你的问题被标记为“ftp”,我想这可能会帮助你。在

看看python中的ftplib,它同时适用于python2.x和3.x

>>> from ftplib import FTP
>>> ftp = FTP('ftp.debian.org')     # connect to host, default port
>>> ftp.login()                     # user anonymous, passwd anonymous@
'230 Login successful.'
>>> ftp.cwd('debian')               # change into "debian" directory
>>> ftp.retrlines('LIST')           # list directory contents
-rw-rw-r     1 1176     1176         1063 Jun 15 10:18 README
...
drwxr-sr-x    5 1176     1176         4096 Dec 19  2000 pool
drwxr-sr-x    4 1176     1176         4096 Nov 17  2008 project
drwxr-xr-x    3 1176     1176         4096 Oct 10  2012 tools
'226 Directory send OK.'
>>> ftp.retrbinary('RETR README', open('README', 'wb').write)
'226 Transfer complete.'
>>> ftp.quit()

有关ftplib模块的更多信息:

This module defines the class FTP and a few related items. The FTP class implements the client side of the FTP protocol. You can use this to write Python programs that perform a variety of automated FTP jobs, such as mirroring other ftp servers. It is also used by the module urllib to handle URLs that use FTP. For more information on FTP (File Transfer Protocol), see Internet RFC 959.

在python文档中查找2.x here和{a2}的ftplib模块。在

相关问题 更多 >

    热门问题