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
Python Articles - Page 993 of 1048
16K+ Views
There are various ways to get the file creation and modification datetime in Python. We will use different methods from the OS and pathlib module to get the file creation and modification datetime in Python. Using OS Module: File Creation Time On Windows Using OS Module: File Modification Time On Windows ... Read More
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 will have to convert these strings into date objects. To achieve this, we can use Python's datetime and dateutil modules. Using the strptime() Function The strptime() method takes the date as input and converts it into a ... Read More
112K+ 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 Strftime() Function The strftime() function returns a formatted date and time. It accepts a format string that you can use to get the ... Read More
1K+ 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. Here are the different ways to get the current Date and Time using the Datetime Module - Using the now() Method Using the today() Method Current ... Read More
248 Views
In this article we will show you how you can print complete TimeTuple in Python. So printing a complete timeTuple in Python is very useful when you want to extract various parts of a date. For example you can use it to get the year, month, day, hour, minute, second and microsecond from a date. The time tuple is a tuple of 9 integers like year, month, day, hour, minute, second and microsecond. The first 6 items are required and the last 3 are optional basically. Here are different ways to do this task and print a time tuple - ... Read More
2K+ Views
In this article, we will show you how you can get the timer ticks at the given time using different functions in Python. To get the timer ticks at the given time, there is a time module available in Python. Here is the list of ways to solve this problem - Using time.time() Function Using time.perf_counter() Function Using time.process_time() Function Let us discuss each of these methods one by one in the section below - Using time.time() Function The time.time() function is used to get the current time in seconds. It returns the number of seconds since the ... Read More
2K+ Views
In Python, a tick is the floating-point number to show time in seconds since January 1, 1970. This is mainly used in time calculations and logging timestamps in programs. Python's time module givens the function time.time() to fetch the current tick value. It is very useful for measuring execution tracks time in seconds. Also it helps in scheduling tasks with timestamps. Using Tick in Python The time.time() function from the time module gets the current tick value. This value increases as time moves forward. This method does not accept any parameters, as it always returns the current UTC time. ... Read More
24K+ Views
In this article, we will discuss how to extract a list of all the values from a Python dictionary. Following are various ways to retrieve list of all the values from a Python dictionary - Using dict.values() & list() Functions Using [] and * Using List comprehension ... Read More
51K+ Views
In this article, we will show you how to get a list of all the keys from a Python dictionary. We can get the list of all the keys from a Python dictionary using the following methods - Using dict.keys() Method Using list() & dict.keys() Function Using List Comprehension ... Read More
34K+ Views
In this article, we will show you how to get a value for the given key from a dictionary in Python. Below are the 4 different methods to accomplish this task - Using Dictionary Indexing Using dict.get() Method Using keys() Function Using items() Function Assume we have taken a dictionary containing key-value pairs. We will return the value for a given key from a given input dictionary. Using dictionary indexing In Python, we can retrieve the value from a dictionary by using dict[key]. Example 1 The following program returns the index of the value for a given key ... Read More