简体   繁体   中英

move to forward or backward - Python - ftplib

I am intended to create a GUI FTP application by using Python and PyGTK. So I have chosen ftplib.

Requirement is I want to create two buttons. Butoon 1 Forward and Button 2 Backward. When I click backward then it have to move to last directory. If I assume my object and function as

ftp.cwd() then What I have to pass as an argument ie ftp.cwd(something that send to backward).

Help me Please.

Thank you.

.cwd() is the correct method to change the remote (on ftp server) directory.

something that send to backward

To implement forward/backward buttons, you need a list of previously visited directories. You could use collections.deque() that has .rotate() method that allows to move forwards and backwards in the history list.

You could use maxlen parameter to limit the history size. .append() adds a new item to the history. Each item may be a simple string representing the remote path. You can pass these strings to .cwd() method to change the directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM