• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 在Python中移动目录结构的方法

在Python中移动目录结构的方法

作者:mdxy-dxy 字体:[增加 减小] 来源:互联网

mdxy-dxy 通过本文主要向大家介绍了python 目录结构,python 当前目录,python安装目录,python 文件目录,python 创建目录等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

来源:http://stackoverflow.com/questions/3806562/ways-to-move-up-and-down-the-dir-structure-in-python

#Moving up/down dir structure
print os.listdir('.') # current level
print os.listdir('..') # one level up
print os.listdir('../..') # two levels up
 
# more complex example:
# This will walk the file system beginning in the directory the script is run from. It 
# deletes the empty directories at each level
 
for root, dirs, files in os.walk(os.getcwd()):
  for name in dirs:
    try:
      os.rmdir(os.path.join(root, name))
    except WindowsError:
      print 'Skipping', os.path.join(root, name)			
</div>

This will walk the file system beginning in the directory the script is run from. It deletes the empty directories at each level.

</div>

您可能想查找下面的文章:

  • 在Python中移动目录结构的方法

相关文章

  • Python实现发送email的几种常用方法
  • Python实现将DOC文档转换为PDF的方法
  • python处理图片之PIL模块简单使用方法
  • 详解Python中的循环语句的用法
  • Windows下Python的Django框架环境部署及应用编写入门
  • 通过源码分析Python中的切片赋值
  • python使用pil生成图片验证码的方法
  • 跟老齐学Python之用Python计算
  • Python处理JSON时的值报错及编码报错的两则解决实录
  • Python 爬虫学习笔记之多线程爬虫

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python中的zipfile模块使用详解
    • python脚本监控docker容器
    • python使用cookie库操保存cookie详解
    • 基于Python实现的百度贴吧网络爬虫实例
    • 利用Python中unittest实现简单的单元测试实例详解
    • 在Python中用get()方法获取字典键值的教程
    • Python的几个高级语法概念浅析(lambda表达式闭包装饰器)
    • Python远程桌面协议RDPY安装使用介绍
    • Python、Javascript中的闭包比较
    • python遍历文件夹并删除特定格式文件的示例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有