API文档:
os.path.join(path1[, path2[, ...]])
Join one or more path components intelligently. If any component is an absolute path, all previous components (on Windows, including the previous drive letter, if there was one) are thrown away, and joining continues. The return value is the concatenation of path1, and optionally path2, etc., with exactly one directory separator (os.sep) inserted between components, unless path2 is empty. Note that on Windows, since there is a current directory for each drive, os.path.join("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not c:\foo.
翻译文档:
连接一个或多个文件路径,例如:os.path.join('c:/',''foo'),输出:c:/foo
例子:
#! /usr/bin/env python
#coding=utf-8
import os
pathStr = 'c:/'
fList = [os.path.normcase(el) for el in os.listdir(pathStr)]
fList = [os.path.join(pathStr,f) for f in fList]
print fList
输出:
['c:/$recycle.bin', 'c:/360downloads'......]