|
|
发表于 2018-1-17 14:02:59
|
显示全部楼层
回帖奖励 +1 鱼币
本帖最后由 sky 于 2018-1-17 14:05 编辑
os.listdir返回包含路径下所有文件和文件夹名字的列表
如果是os.curdir后面的路径使用的就是相对路径
如果你改用绝对路径 后面就需要路径字符串拼接 否则不是有效路径了哦
- >>> help(os.listdir)
- Help on built-in function listdir in module nt:
- listdir(path=None)
- Return a list containing the names of the files in the directory.
- path can be specified as either str or bytes. If path is bytes,
- the filenames returned will also be bytes; in all other circumstances
- the filenames returned will be str.
- If path is None, uses the path='.'.
- On some platforms, path may also be specified as an open file descriptor;\
- the file descriptor must refer to a directory.
- If this functionality is unavailable, using it raises NotImplementedError.
- The list is in arbitrary order. It does not include the special
- entries '.' and '..' even if they are present in the directory.
复制代码 |
|