博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python path operations
阅读量:6902 次
发布时间:2019-06-27

本文共 1408 字,大约阅读时间需要 4 分钟。

os.madedirs:

os.
makedirs
(
path,
mode=0o777,
exist_ok=False
)

Recursive directory creation function. Like , but makes all intermediate-level directories needed to contain the leaf directory. If the target directory with the same mode as specified already exists, raises an exception if exist_ok is False, otherwise no exception is raised. If the directory cannot be created in other cases, raises an exception. The default mode is 0o777 (octal). On some systems, mode is ignored. Where it is used, the current umask value is first masked out.

Note

will become confused if the path elements to create include .

This function handles UNC paths correctly.

New in version 3.2: The exist_ok parameter.

os.path.abspath:

os.path.
abspath
(
path
)

Return a normalized absolutized version of the pathname path. On most platforms, this is equivalent to normpath(join(os.getcwd(), path)).

os.path.basename:

os.path.
basename
(
path
)

Return the base name of pathname path. This is the second half of the pair returned by split(path). Note that the result of this function is different from the Unix basename program; where basename for '/foo/bar/' returns 'bar', the function returns an empty string ('').

os.path.dirname:

os.path.
dirname
(
path
)

Return the directory name of pathname path. This is the first half of the pair returned by split(path).

转载于:https://www.cnblogs.com/kongs/archive/2011/11/18/2253931.html

你可能感兴趣的文章
php 框架ci去index.php的方法
查看>>
Hyper-v学习(四),SMB虚拟机实时迁移
查看>>
基于spring3注解的google分页
查看>>
实用命令行工具详解—crontab
查看>>
code review
查看>>
我的心灵旅程:2019重新开始
查看>>
设置vim根据文件类型选择相应的编译器
查看>>
redis+ssh-keygen免认证登录案例
查看>>
HTML_后台框架全屏界面_fixed形式布局
查看>>
为什么使用 SLF4J 而不是 Log4J 来做 Java 日志
查看>>
顺丰快递接口
查看>>
淘宝技术发展(个人网站)
查看>>
处理 emoji 表情
查看>>
Dev-No.02 HTTP Status状态汇总
查看>>
linux svn命令
查看>>
Android中获取CPU负载和进程cpu时间
查看>>
docker容器启动后添加端口映射
查看>>
Android新姿势:3D翻转效果原理
查看>>
Xtrabackup系列之:二进制安装
查看>>
Context []startup failed due to previous errors 错误
查看>>