「Python」remove関数でファイルを削除する

書式
os.remove(ファイルパス名)
remove関数を利用して、指定ファイルを削除します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# coding: utf-8
import os
filePath = "C:\\study\\testA.csv"
os.remove(filePath)
# coding: utf-8 import os filePath = "C:\\study\\testA.csv" os.remove(filePath)
# coding: utf-8
import os

filePath = "C:\\study\\testA.csv"

os.remove(filePath)

結果
「testA.csv」を削除します。

Python

Posted by arkgame