Server Side Programming Articles

Page 641 of 2109

How to compare regular expressions in Perl and Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 513 Views

This article compares regular expressions in Perl and Python, showing syntax differences and practical examples. Regular expressions are patterns used to match and manipulate strings in both languages. The key difference is syntax: Perl uses $text =~ /pattern/ while Python uses re.search('pattern', text). Let's explore practical examples comparing both approaches. Check if a String Contains a Word Both languages can search for specific words in text, but use different syntax. Python Example Python uses the re.search() function to find patterns in strings ? import re text = "Hello Tutorialspoint" match = re.search(r"Tutorial", ...

Read More

What is difference between \'.\' , \'?\' and \'*\' in Python regular expression?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 644 Views

This article will discuss the difference between dot '.', question mark '?', and asterisk '*' in Python regular expressions. In regular expressions, '.' means any one character except the newline, '*' means zero or more occurrences of the preceding character or group, and '?' means zero or one occurrence of the preceding character or group. The question mark can also make quantifiers non-greedy in some contexts. Let's understand these symbols using practical examples ? Usage of Dot (.) The dot '.' matches any single character except a newline ? import re # Define ...

Read More

What is Raw String Notation in Python regular expression?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 6K+ Views

Raw string notation in Python regular expressions helps avoid backslash conflicts by treating backslashes as literal characters rather than escape sequences. This is especially important when writing regex patterns that contain backslashes. The Problem with Regular Strings In regular Python strings, backslashes have special meaning for escape sequences like (newline) and \t (tab). This can interfere with regex patterns that need literal backslashes ? import re # Without raw string - needs double backslashes pattern = "\d+" text = "There are 123 items" matches = re.findall(pattern, text) print("Without raw string:", matches) ...

Read More

How to convert a Python date string to a date object?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 9K+ Views

In this article, we convert a date string to a date object. We will use the strptime() method to convert a date string to a date object, and we will also use the dateutil module for flexible date parsing. A date string is a date written in text form, like "09 May 2025" or "2025-05-09". To work with dates in Python, we need to convert these strings into date objects. We can achieve this using Python's datetime and dateutil modules. Using the strptime() Function The strptime() method takes a date string as input and converts it into ...

Read More

How to get formatted date and time in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 113K+ Views

This article will discuss how to format date and time in Python. Python makes it easy to work with date and time with the help of the datetime module. You can format dates and times in different formats as per your needs. Datetime Module of Python The datetime module in Python offers methods for working with date and time values. To use this module, we must first import it using the following import keyword − import datetime The strftime() Function The strftime() function returns a formatted date and time string. It accepts a ...

Read More

How to get current date and time in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 2K+ Views

In this article, we will show you how you can get the current time and date in Python with the help of different functions. Python provides two main modules for working with date and time: the datetime module and the time module. Using the Datetime Module Date and time are not data types in Python, but you can work with them using the datetime module. The datetime module is included in Python, so there is no need to install it separately. Using the now() Method The now() method returns the current local date and time ? ...

Read More

How to print complete TimeTuple in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 332 Views

In Python, a TimeTuple is a named tuple containing 9 elements that represent different components of date and time. The timetuple() method converts datetime objects into this structured format, making it easy to access individual time components like year, month, day, hour, minute, and second. The time tuple contains 9 integers: year, month, day, hour, minute, second, weekday, year day, and daylight saving time flag. Here are different ways to print a complete time tuple ? Using datetime.date.today() ...

Read More

How to get timer ticks at a given time in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 3K+ Views

In this article, we will show you how to get timer ticks at a given time using different functions in Python. Timer ticks represent time measurements that help track execution time, current time, and performance metrics. The time module in Python provides several functions to work with time measurements. Here are the main approaches to solve this problem ? Using time.time() Function Using time.perf_counter() Function Using time.process_time() Function Using time.time() Function The time.time() function returns the current time in seconds since the Unix epoch (January 1, 1970). It's useful for getting timestamps and measuring ...

Read More

What is a Tick in python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 3K+ Views

In Python, a tick is a floating-point number representing time in seconds since January 1, 1970, 00:00:00 UTC (also known as the Unix epoch). This timestamp format is widely used for time calculations, logging, and scheduling tasks in Python programs. The time.time() function from Python's time module returns the current tick value, making it essential for measuring execution time and working with timestamps. Getting the Current Tick Value The time.time() function retrieves the current tick value. This value continuously increases as time progresses and represents UTC time ? Example import time # Get ...

Read More

How does the del operator work on a tuple in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 6K+ Views

A tuple is an ordered and immutable collection of Python objects separated by commas. Like lists, tuples are sequences. Tuples differ from lists in that they cannot be modified, whereas lists can, and they use parentheses instead of square brackets. Though we cannot change individual elements of a tuple, the del operator works with them. In this article, we are going to discuss how the del operator works on tuples in Python. The del Operator with Tuples The del operator in Python is used to delete variables from the current scope. When you use del on a ...

Read More
Showing 6401–6410 of 21,090 articles
« Prev 1 639 640 641 642 643 2109 Next »
Advertisements