TA贡献1793条经验 获得超6个赞
file = 'c:/test.txt'if os.path.exists(file):os.remove(file)else:print 'no such file:%s' % file
TA贡献1825条经验 获得超6个赞
使用os包的remove方法可以删除文件
1
2
3
4
import os
filename = 'f:/123.txt'
if os.path.exist(filename):
os.remove(filename)
TA贡献1827条经验 获得超9个赞
import osos.unlink("filename")
测试技术的修炼之道
¥ 48.00
Python 源码深度剖析
¥ 68.00
Python 数据分析通关攻略
¥ 58.00
你的第一本Python基础入门书
从 0 开始学爬虫
举报