how to delete a file in python?

0 votes
how to delete a file or a folder in python?
Mar 18 in Python by Waseem
• 4,270 points
15 views

1 answer to this question.

0 votes

to delete a file

import os
os.remove('filename')

this will delete the file.

answered Mar 18 by Mohammad
• 3,060 points

Related Questions In Python

0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,520 points
45 views
0 votes
1 answer

How to write data to a file in Python?

Refer to the below code. data=’whatever your data ...READ MORE

answered May 12 in Python by Shaam
26 views
0 votes
1 answer
0 votes
1 answer

How to read a large file, line by line, in Python?

The correct, fully Pythonic way to read ...READ MORE

answered Jul 1 in Python by SDeb
• 13,160 points
21 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 175 views
0 votes
1 answer

how to check for exceptions in a file?

try { if (!file.exists("TextFile1.txt")) throw ...READ MORE

answered Mar 20 in Python by Mohammad
• 3,060 points
13 views
0 votes
1 answer

How can I write a program to add two numbers using functions in python?

def add(a,b):      return a + b #when i call ...READ MORE

answered May 20 in Python by Mohammad
• 3,060 points
46 views