
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10451 Articles for Python

243 Views
Printing a String Twice Using Multiplication When we are developing Python, we may want to repeat or duplicate a string for display or formatting purposes. In such cases, Python provides several ways to print a string in defined number of times with a single statement. There are different ways to print a string twice with a single statement in Python. They are - Using Multiplication Operator Using the Concatenation Operator Using the format() Method Using f-string Using join() ... Read More

355 Views
The following code splits given string by a period and a line break as followsExampleimport re s = """Hi. It's nice meeting you. My name is Jason.""" result = re.findall(r'[^\s\.][^\.]+', s) print resultOutputThis gives the following output['Hi', "It's nice meeting you", 'My name is Jason']

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 matching - ... Read More

4K+ 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

16K+ Views
File manipulation is a fundamental aspect of programming, especially when dealing with data processing and management. Python offers powerful tools for handling files and text efficiently. A common task is searching for specific text patterns within a file and replacing them with desired content. This article explores several practical methods for searching and replacing text in a file using Python. Basic Text Replacement Let's start with a simple example of searching for a specific word in a file and replacing it with another word. In this particular example, we'll search for the word "old" and replace it with "new" − ... Read More

1K+ Views
In Python, Regular expressions are also called RegEx, which is a sequence of characters that defines a search pattern. The re module provides several functions to work with patterns in text. This is widely used in Python tasks such as string matching, validation, and manipulation. The most commonly used functions in the "re" module are re.match() and re.search(). These two methods are used to check for the presence of a pattern, but they differ in the way they look for a pattern match within a string. In this article, we are going to see the difference between the Python re.search() ... Read More

18K+ Views
To handle strings and text-related operations Python provides the search() function, an integral component of the re (regular expression) module, which scans through a string and looks for a match to a specified regular expression pattern. Understanding Regular Expressions Regular Expressions ("regex" or "regexp") are powerful tools for matching and manipulating strings. They consist of a sequence of characters that define a search pattern, making them necessary for tasks such as validation, data extraction, and text processing. The 'search()' Function in Python The search() function enables the search for specified patterns within a given string. If a match is found, ... Read More

17K+ Views
In Python programming, while working with strings and manipulating text the match() function, a part of the built-in 're' module, provides various pattern matching techniques used in regular expressions (regex). The match() function is used for a pattern at the start of a given string. If the pattern is found, it returns a match object representing the match. If not, it returns None. This is different from the 'search()' function, which searches for the pattern anywhere within the string. Pattern Matching Using the match() Function Let's begin with a simple example demonstrating the match() function. In this example, we search ... Read More

6K+ Views
SSH is referred as secure shell which is useful to remotely manage computers in a secure manner. To connect to a server, we typically use PuTTy, MobaXTerm or the command-line ssh application. Every Unix, Linux and Mac server includes SSH as standard equipment and it is usable in every data centre. SSH connections have made it feasible for secure remote access to resources, remote command execution, the transmission of software patches and updates and other administrative or management tasks. SSH is used in systems administration and file transfer software as well as to handle routers, server hardware, virtualization platforms and ... Read More

403 Views
In Python we can use FTP (File Transfer Protocol) by importing the ftplib module, it will provide a simple interface to access FTP servers to retrieve files and process them locally. ftplib module allows us to write Python programs that perform a variety of automated FTP tasks. Objectives of FTP The objectives of FTP are as follows FTP provides file sharing. FTP helps us to encourage the use of remote computers. FTP is used to transfer the data reliably and efficiently. Some Common tasks we can perform using FTP in Python by utilizing the 'ftplib' module are as follows: ... Read More