Python3 os.rmdir() 方法
Python 3 教程
· 2019-02-07 19:12:19
概述
os.rmdir() 方法用于删除指定路径的目录。仅当这文件夹是空的才可以, 否则, 抛出OSError。
语法
rmdir()方法语法格式如下:
os.rmdir(path)
参数
path -- 要删除的目录路径
返回值
该方法没有返回值
实例
以下实例演示了 rmdir() 方法的使用:
#!/usr/bin/python3
import os, sys
# 列出目录
print ("目录为: %s"%os.listdir(os.getcwd()))
# 删除路径
os.rmdir("mydir")
# 列出重命名后的目录
print ("目录为: %s" %os.listdir(os.getcwd()))
执行以上程序输出结果为:
目录为: [ 'a1.txt','resume.doc','a3.py','mydir' ] 目录为: [ 'a1.txt','resume.doc','a3.py' ]
点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html
HTML & XHTML
Chuck Musciano、Bill Kennedy / O'Reilly Media / 2006-10-27 / GBP 39.99
"...lucid, in-depth descriptions of the behavior of every HTML tag on every major browser and platform, plus enough dry humor to make the book a pleasure to read." --Edward Mendelson, PC Magazine "Whe......一起来看看 《HTML & XHTML》 这本书的介绍吧!