python Programming Glossary: filelist
Downloading text files with Python and ftplib.FTP from z/os http://stackoverflow.com/questions/1184844/downloading-text-files-with-python-and-ftplib-ftp-from-z-os DLLC DLMC GEN HDR MAC sess.cwd 'ZLTALM.PREP. s' dir try filelist sess.nlst except ftplib.error_perm as x if x.args 0 3 '550'.. else try os.mkdir dir except continue for hostfile in filelist lines sess.retrlines RETR hostfile lines.append pcfile open..
Deleting all files in a directory with Python http://stackoverflow.com/questions/1995373/deleting-all-files-in-a-directory-with-python this question Via os.listdir and os.remove import os filelist f for f in os.listdir . if f.endswith .bak for f in filelist.. f for f in os.listdir . if f.endswith .bak for f in filelist os.remove f Or via glob.glob import glob os filelist glob.glob.. f in filelist os.remove f Or via glob.glob import glob os filelist glob.glob .bak for f in filelist os.remove f Be sure to be in..
how to replace (update) text in a file line by line http://stackoverflow.com/questions/4778697/how-to-replace-update-text-in-a-file-line-by-line for line in f.readlines if ' a href ' in line for test in filelist pathmatch file_match line test if pathmatch is not None repstring.. file_match line test if pathmatch is not None repstring filelist test pathmatch print 'old line ' line line line.replace test.. for line in lines if ' a href ' in line for test in filelist pathmatch file_match line test if pathmatch is not None repstring..
|