''' Created on 2011-8-3
@author: Killua @E-mail:[email protected] @Description: '''
import os
def file_path_info(filename): print("OS:" + os.name) print("split:", os.path.split(filename)) print("splitext:", os.path.splitext(filename)) print("dirname:", os.path.basename(filename)) print("basename:" + os.path.basename(filename))
def list_files(directory): stack = [directory] files = [] while stack: directory = stack.pop() for file in os.listdir(directory): fullname = os.path.join(directory, file) files.append(fullname) if os.path.isdir(fullname) and not os.path.islink(fullname): stack.append(fullname) for file in files: print(file)
def main(): list_files("/home/killua")
if __name__ == "__main__": main()
|