import osif os.name == "nt" or os.name == "dos": fileList = "dir /B" sortReverse = "sort /R"elif os.name == "posix": # UNIX-compatible system fileList = "ls -1" sortReverse = "sort -r"else: sys.exit( "OS not supported by this program." )dirOut = os.popen( fileList, "r" )sortIn, sortOut = os.popen2( sortReverse )filenames = dirOut.read() print "(Output from '%s'):" % fileListprint filenamessortIn.write( filenames ) dirOut.close()sortIn.close()print "(Output from '%s'):" % sortReverseprint sortOut.read() sortOut.close()
Name (required)
email (will not be published) (required)
Website