os.path.join('c' 'folder') # 'c\\folder' os.path.join('c:' 'folder') # 'c:folder' # Get file name. os.path.basename('C:\\Windows\\123.txt') # '123.txt' # Get file path and file extension. filePath, fileExtension = os.path.splitext('C:\\Windows\\123.txt') # 'C:\\Windows\\123', '.txt' # Get directory path. os.path.dirname('C:\\Windows\\123.txt') # 'C:\\Windows' # Get modify time from epoch time. os.path.getmtime('C:') # 1409646173.7839031 # Traverse a directory. for root, subdirs, files in os.walk("C:\\Pictures"): print root, subdirs, files
沒有留言:
張貼留言