TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊
file = 'c:/test.txt'if os.path.exists(file):os.remove(file)else:print 'no such file:%s' % file
TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
使用os包的remove方法可以刪除文件
1
2
3
4
import os
filename = 'f:/123.txt'
if os.path.exist(filename):
os.remove(filename)
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊
import osos.unlink("filename")
測(cè)試技術(shù)的修煉之道
¥ 48.00
Python 源碼深度剖析
¥ 68.00
Python 數(shù)據(jù)分析通關(guān)攻略
¥ 58.00
你的第一本Python基礎(chǔ)入門(mén)書(shū)
從 0 開(kāi)始學(xué)爬蟲(chóng)
舉報(bào)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)