We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Category: FileHandling

How to create a Directory in python ?

In this article we will discuss different APIs in python to create directories. Creating a Directory in Python Python’s OS module provides a function to create a directory i.e. Advertisements os.mkdir(path) It creates a directory with given path i.e. os.mkdir(‘tempDir’) It creates the directory ‘tempDir’ in current directory. Frequently Asked: Find the smallest file in …

How to create a Directory in python ?Read More

How to change current working directory in python ?

In this article we will discuss how to change the current working directory in python. Current working directory is the directory in which program is running. Advertisements Change Current Working Directory in Python First of all we need to import python’s os module i.e. import os Python’s os module provides a function to change the …

How to change current working directory in python ?Read More

Python : How to move files and Directories ?

In this article we will discuss different ways to move files and directories in python. In python we have a shutil module that provides various files related operations.  To import the shutil module use following line, Advertisements import shutil It also provides functions to move files i.e. shutil.move(src, dst) It accepts source and destination path as …

Python : How to move files and Directories ?Read More

Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()

In this article we will discuss different ways to get the last modification date & time of a file and how to convert them into different formats. Get last modification time of a file using os.stat() os.stat(pathOfFile) It returns the status of file in the form of an os.stat_result object. It contains information related to a …

Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()Read More

Python : How to copy files from one location to another using shutil.copy()

In this article we will discuss how to copy files from one directory to another using shutil.copy(). shutil.copy() Python’s shutil module provides a function shutil.copy() i.e. Advertisements shutil.copy(src, dst, *, follow_symlinks=True) It copies the file pointed by src to the directory pointed by dst. Parameters: Frequently Asked: Python : How to remove files by matching …

Python : How to copy files from one location to another using shutil.copy()Read More

Python : How to get Last Access & Creation date time of a file

In this article we will discuss different ways to get the last access and creation timestamp of a file and how to convert them into different formats. os.stat() Python’s os module provides a function os.stat() Advertisements os.stat(pathOfFile) It accepts the path of file as argument and returns the status of file in the form of an …

Python : How to get Last Access & Creation date time of a fileRead More

Python : How to remove files by matching pattern | wildcards | certain extensions only ?

In this article we will discuss how to delete few files from a directory based on matching pattern or wildcard. Suppose we have a directory that contains some log files and some text files and we want to delete all .txt files from that directory i.e. files that ends with string “.txt”. Let’s discuss how …

Python : How to remove files by matching pattern | wildcards | certain extensions only ?Read More

Python : How to remove a file if exists and handle errors | os.remove() | os.ulink()

In this article we will discuss how to remove a file if only it exists and how to handle other types of exceptions using os.remove() & os.ulink(). How to remove a file using os.remove() python ‘s os module provides a function to remove the file i.e. Advertisements os.remove(path_of_file) It accepts the file path as argument …

Python : How to remove a file if exists and handle errors | os.remove() | os.ulink()Read More

Cart

Your Cart is Empty

Back To Shop