python ftp_Python FTP

python ftp

Today we will learn about python ftp operations. FTP is an acronym for File Transfer Protocol. Just like what it sounds, this protocol is used to transfer files across a network from source to destination machine.

今天,我们将学习python ftp操作。 FTP是文件传输协议的缩写。 就像听起来一样,此协议用于在网络上从源计算机到目标计算机传输文件。

In this post on python ftp module, we will see how to connect to a FTP server, upload & download files and much more. Let’s get started.

在python ftp模块的这篇文章中,我们将看到如何连接到FTP服务器,上传和下载文件等等。 让我们开始吧。

Python的FTP (Python ftp)

With Python, ftplib module provides all the functions which we might need to perform actions across the FTP protocol. Let’s start exploring this lesson with simple connection attempt.

使用Python, ftplib 模块提供了我们可能需要跨FTP协议执行操作的所有功能。 让我们通过简单的连接尝试开始本课。

使用login()函数连接到FTP服务器 (Connecting to an FTP server with login() function)

We will start by making a connection to an FTP server. We will use a server publicly available for usage, ftp.cse.buffalo.edu. Feel free to choose any server, just make sure you select the right server otherwise you will face connection errors.

我们将从建立与FTP服务器的连接开始。 我们将使用可供使用的ftp.cse.buffalo.edu服务器ftp.cse.buffalo.edu 。 随意选择任何服务器,只需确保选择正确的服务器,否则将面临连接错误。

We will write a simple script to connect to the said server:

我们将编写一个简单的脚本来连接到所述服务器:

from ftplib import FTP

# Host to connect to
host = 'ftp.cse.buffalo.edu'

# Make an Python FTP object and anonymously login
ftp = FTP(host)
print(ftp.login())

See how we can login without a username and a password? That is supported by few servers only. Let us see the output:

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值