I am Struggling to Understand a Python Code Snippet



  • import os
    import socket
    hostname = socket.gethostname()
    IPAddr = socket.gethostbyname(hostname)
    print("Your Computer Name is:" + hostname)
    print("Your Computer IP Address is:" + IPAddr)
    def main():
    fo = open( "data.ftpftp",'r')

    from ftplib import FTP

    ftp = FTP('ftp.cwi.nl') # connect to host, default port

    ftp.login() # user anonymous, passwd anonymous@

    ftp.retrlines('LIST') #
    import ftplib

    ftp = ftplib.FTP('ftp.sunet.se', 'anonymous', 'anonymous@sunet.se')

    print ("File List: ")

    files = ftp.dir()

    print(files)

    ftp.cwd("/pub/unix") #changing to /pub/unix



  • We love to help but you have to help us understand what exactly your are looking for. As in what specifically do you need help with? What is wrong with the code? etc.


Log in to reply