Python os.remove() 方法
Python 教程
· 2019-02-04 09:56:33
概述
os.remove() 方法用于删除指定路径的文件。如果指定的路径是一个目录,将抛出OSError。
在Unix, Windows中有效
语法
remove()方法语法格式如下:
os.remove(path)
参数
path -- 要移除的文件路径
返回值
该方法没有返回值
实例
以下实例演示了 remove() 方法的使用:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 列出目录 print "目录为: %s" %os.listdir(os.getcwd()) # 移除 os.remove("aa.txt") # 移除后列出目录 print "移除后 : %s" %os.listdir(os.getcwd())
执行以上程序输出结果为:
目录为: [ 'a1.txt','aa.txt','resume.doc' ] 移除后 : [ 'a1.txt','resume.doc' ]
点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html
Ruby for Rails
David Black / Manning Publications / 2006-05-11 / USD 44.95
What's Inside * How Ruby and Rails work, separately and together * Extensive Ruby language tutorial * Ruby techniques for Rails applications * Explore the Rails framework source code A new level of pr......一起来看看 《Ruby for Rails》 这本书的介绍吧!
CSS 压缩/解压工具
在线压缩/解压 CSS 代码
XML 在线格式化
在线 XML 格式化压缩工具