Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove directory not empty

import shutil

shutil.rmtree('/folder_name')
shutil.rmtree('/folder_name', ignore_errors=True)  # for read only files
Comment

empty directory if not empty python

'''
    Check if a Directory is empty : Method 1
'''    
if len(os.listdir('/home/varun/temp') ) == 0:
    print("Directory is empty")
else:    
    print("Directory is not empty")
Comment

PREVIOUS NEXT
Code Example
Python :: pattern program in python A aB bCc DdEe 
Python :: text replace 
Python :: find max, min character 
Python :: code help 
Python :: how can space be bent 
Python :: convert json file to dict - if comming as list 
Python :: jupyter notebook do not show matplotlib text above plot 
Python :: eager tensor to numpy 
Python :: how to take matrix input in python 
Python :: rename column in dataframe 
Python :: check if a variable is empty python 
Python :: Python[17586:513448] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to 
Python :: python no mathcing key method found 
Python :: Select a Column in pandas data Frame Using Brackets 
Python :: how to get key stroke pygame 
Python :: deploy vue app to google cloud run 
Python :: python class optional arguments 
Python :: python autorun script 
Python :: python list of all definitions in python file 
Python :: adding multiple items to a list python 
Python :: method 01 of making GUI with tkinter in python 
Python :: symmetric_difference_update() Function of sets in python 
Python :: numpy retrieve 5 highest value index 
Python :: when to use static method in python 
Python :: convert set to list python time complexity method 2 
Python :: Sampling data in different ways 
Python :: first flask api 
Python :: generate natural numbers python 
Python :: python Access both key and value using iteritems() 
Python :: prefix in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =