我必须制作一个程序,根据从ftp服务器生成的文件中提取的数据生成表,这些文件每天都在服务器ftp的目录中生成,因此必须每天生成表。 一切都必须用python完成 有没有人有任何想法? 对不起,我尝试过这个程序:
import ftplib
# Connection information
server = 'ftp0.micasa.es'
username = 'anonymous'
password = '---------'
# Directory and matching information
directory = '/expl/publico/MI_HABITACION/'
filematch = '*.txt'
# Establish the connection
ftp = ftplib.FTP(server)
ftp.login(username, password)
# Change to the proper directory
ftp.cwd(directory)
# Loop through matching files and download each one individually
for filename in ftp.nlst(filematch):
fhandle = open(filename, 'wb')
print ('Getting ' + filename)
ftp.retrbinary('RETR ' + filename, fhandle.write)
fhandle.close()
程序运行并且不会出错,但它不会在屏幕上打印任何内容或在任何地方显示文件。
答案 0 :(得分:0)
使用一些像Flask / Django这样的Web开发框架。您还可以使用它们将数据存储在数据库中,并在HTML页面中将它们显示为表格。