Rajendra Dharmkar has Published 189 Articles

How to delete a character from a string using python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:44:58

994 Views

Here are some examples of how to delete a character from a string using Python. Using String Slicing One of the easiest ways to delete a character from a string in Python is to use string slicing. Here's how you can do it: Example In the first line of ... Read More

How do I check if raw input is integer in Python 3?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 14:49:54

9K+ Views

In Python 3, the input() function always returns a string, even if the user enters a number. To check if the user input is an integer, you can use a try-except block and attempt to convert the input string to an integer using the int() function. Here are some code ... Read More

Does Python have a string 'contains' substring method?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 12:02:36

631 Views

In Python, a substring is a sequence of characters that appears within a larger string. For example, in the string "Hello, world!", the substring "world" appears within the larger string. A substring can be a single character, or it can be a longer sequence of characters. Substrings are useful when ... Read More

Can we do math operation on Python Strings?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 11:54:19

4K+ Views

You can perform some math operations on Python strings technically, but it may not work the way you expect it to. Here are a few examples: Concatenating Strings with + Example In this example, we concatenate two strings by using the + operator. This works because the + operator is ... Read More

How to execute a Python file in Python shell?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 03-Aug-2023 11:21:15

8K+ Views

Venturing further into the realm of Python programming, you'll undoubtedly encounter scenarios where executing a Python file from within the Python shell becomes essential. This capability endows you with the power to test, run, and interact with your Python scripts seamlessly without exiting the Python environment. Within this article, we ... Read More

How to write binary data to a file using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jul-2023 09:59:05

54K+ Views

It is a common and routine task in Python; the act of writing binary data to a file when you need to save non-textual data such as images, audio files, or serialized objects. In this article, we will explore various ways how you can write binary data to a file ... Read More

How to set the current working directory in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jul-2023 09:50:41

2K+ Views

The current working directory in Python is defined as the directory from where the Python script is being executed. By default, the current working directory is usually the directory where the script is stored, located or resides. However, there may arise scenarios or instances where you may want to change ... Read More

How to set creation and modification date/time of a file using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jul-2023 09:41:43

14K+ Views

The creation and modification datetime of a file in Python are defined as the timestamps associated with the events of when the file was created and when it was last modified. Creation datetime: It is defined as the timestamp when a file was initially created or added to ... Read More

How to rename multiple files recursively using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jul-2023 09:36:59

4K+ Views

The act of renaming multiple files recursively in Python can be a useful task when it is required to change the names of multiple files within a directory and its subdirectories. If you need to replace certain characters, add prefixes or suffixes, or completely change the file names, Python has ... Read More

How to rename directory using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jul-2023 09:31:07

11K+ Views

There are times when you want to organize your files or update the directory names to better reflect their contents. In such scenarios, the operation of renaming directories becomes helpful and it is a common task that we often encounter in Python file management. There is provision of several modules ... Read More

Advertisements