![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
python_人生苦短
这个作者很懒,什么都没留下…
展开
-
python os模块 常用函数
python os模块常用函数import os"""os.name # 顾名思义就是'名字',这里的名字是指操作系统的名字,主要作用 # 是判断目前正在使用的平台,并给出操作系统的名字,如Windows # 返回 'nt'; Linux 返回'posix'。注意该命令不带括号os.environ原创 2020-05-09 22:16:30 · 164 阅读 · 1 评论 -
python os模块 生成目录树
将指定目录生成目录树。代码:def list_file(start_path): for root, dir, file in os.walk(start_path): # root.dir,file分别是父路径,子目录列表,子文件列表 level = root.replace(start_path, '').count(os.sep) dir_indent = '| ' * level + '|--' file_indent原创 2020-05-09 21:59:53 · 260 阅读 · 0 评论 -
python os模块 复制和删除目录及目录下的文件
python os模块 复制和删除目录及目录下的文件## 标题用python的内置模块os模块对目录及其内部的文件及目录进行复制和删除操作。本文用到的os模块内置函数如下:os.mkdir(path) # 创建path指定的目录,该参数不能省略os.rmdir(path) # 删除path指定的目录,该参数不能省略os.listdir(path) # 列出path目录下所有的文件和目录名原创 2020-05-09 17:57:50 · 2883 阅读 · 0 评论