Pwd() Method Of Ftp Class In Python

Method Name:

pwd

Method Signature:

pwd()

Return Value:

Returns the present working directory.

Method Overview:

  • The method returns the present working directory on the FTP server for the currently logged in user.
  • The FTP command used is PWD.

Example:

# Example python program to get the present working directory

# on the FTP server

from ftplib import FTP

 

# Connect to the FTP server

ftp = FTP(host="agreatftpserver.com");

print(ftp.getwelcome());

 

# Login to the FTP server

respMessage = ftp.login();

print(respMessage);

 

# Get the current working directory

respMessage = ftp.pwd();

print(respMessage);

 

Output:

220 (vsFTPd 3.0.3)

230 Login successful.

/

 

 


Copyright 2023 © pythontic.com