Niharikaa Aitam

Niharikaa Aitam

77 Articles Published

Articles by Niharikaa Aitam

Page 3 of 8

How to match a word in python using Regular Expression?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 5K+ Views

In Python, Regular Expressions (RegEx) are used to match patterns in the given input strings. The re module in Python provides different methods to use the regular expressions. This module helps the developers to perform search operations, validations, filtering, and much more based on string patterns. In this article, we will explore different ways to match a word in Python using the re module. Match a Specific Word using re.search() In Python, the re.search() method is used to search for a pattern within a given string. If the pattern is found, then it returns a match object ...

Read More

How to change any data type into a string in Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 374 Views

In Python, converting different data types into strings is a common requirement when we want to display or store information in text format. The built-in str() function is the primary method for this conversion, accepting any Python object and returning its string representation. Syntax str(object) Where object is any valid Python object, such as int, float, bool, list, etc. Converting Integer to String An integer can be converted into a string using the str() function. This conversion is useful when concatenating numbers with strings ? num = 42 string_num = str(num) ...

Read More

How to print a string two times with single statement in Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 418 Views

When developing Python applications, you may need to repeat or duplicate a string for display or formatting purposes. Python provides several ways to print a string twice with a single statement. There are different approaches to print a string twice with a single statement in Python: Using Multiplication Operator Using the Concatenation Operator Using the format() Method Using f-string Using join() Method with a List Using List Unpacking Using ...

Read More

How can I match the start and end in Python\'s regex?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 2K+ Views

In Python, the re module is used to work with regular expressions. In some cases, we need to check whether a string starts or ends with a specific pattern, and then we need to use special regex characters called anchors. Following are the anchors used in regular expressions − ^ − This anchor matches the beginning of a string. $ − This anchor matches the end of a string. Python Regex Methods The following methods from the re module are commonly used to apply start and end ...

Read More

How do I do a case-insensitive string comparison in Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 5K+ Views

In Python, string comparisons are case-sensitive by default. For example, when we consider the strings "Hello" and "hello" then they are considered as two different strings because of the difference in their letter casing. Case-insensitive String Comparison in Python In some tasks, such as searching user input, comparing filenames, or processing natural language, it's important to compare strings without considering case differences. To perform string comparison in Python, we have several built-in methods such as lower(), upper(), and casefold(), which help us to normalize the casing of strings before comparing them. ...

Read More

What is the difference between Python\'s re.search and re.match?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 2K+ Views

In Python, Regular expressions (RegEx) are sequences of characters that define search patterns. The re module provides several functions to work with patterns in text for tasks like string matching, validation, and manipulation. The most commonly used functions are re.match() and re.search(). Both check for pattern presence but differ in where they look for matches within a string. The re.match() Method The re.match() method checks if the beginning of a string matches the specified pattern. It returns a match object if found at the start, otherwise returns None. Syntax re.match(pattern, string, flags=0) ...

Read More

How to perform different commands over ssh with Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 2K+ Views

When we want to remotely access and execute commands on another machine, we use the paramiko library in Python. Paramiko is a third-party library that enables secure communication with remote machines using the SSH (Secure Shell) protocol. It allows us to execute commands, transfer files, and perform other remote tasks programmatically. To use the Paramiko library, first we need to install it ? pip install paramiko Basic SSH Connection and Command Execution Here's how to connect to a remote server via SSH and execute multiple shell commands ? import paramiko # ...

Read More

How to copy a file to a remote server in Python using SCP or SSH?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 17K+ Views

When we want to transfer files from our local system to a remote server securely, Python provides several ways to do file transfer using the Paramiko and SCP libraries. These libraries support SSH-based file transfer, which is secure and reliable. Installing Required Libraries Before we start with file transfer, we need to install the required libraries ? pip install paramiko scp Understanding SCP and SSH Paramiko is a third-party Python library that provides SSH and SFTP functionality using the SSHv2 protocol. SCP stands for Secure Copy Protocol, which copies files between computers over ...

Read More

How to get the maximum file name length limit using Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 3K+ Views

In Python, when performing file operations such as creating or renaming files, one of the limitations is the maximum length limit of a file name. When we exceed this limit, it results in errors such as OSError: [Errno 36] File name too long. Using os.pathconf() Function In Python, the os.pathconf() function is used to get system-specific configuration values related to files and directories. This function helps in checking limits such as the maximum file name length or the maximum path length allowed by the file system. Syntax Following is the syntax of the os.pathconf() function − ...

Read More

What is the maximum file size we can open using Python?

Niharikaa Aitam
Niharikaa Aitam
Updated on 24-Mar-2026 4K+ Views

In Python, there is no fixed maximum file size that we can open. Python can open files of any size as long as the operating system and file system support it and there is enough memory and disk space available. The limit of maximum file size comes with the system architecture, i.e., 32-bit, 64-bit, the file system, such as FAT32, NTFS, ext4, and how the file is processed in the code. System and File System Limits Following are the system and file system limits ? FAT32 − Maximum file size: 4 ...

Read More
Showing 21–30 of 77 articles
« Prev 1 2 3 4 5 8 Next »
Advertisements