Getting Current Date by Python datetime now() Function
In this tutorial, you are going to learn how to get current date and time by now() function of Python datetime() module.
In this tutorial, you are going to learn how to get current date and time by now() function of Python datetime() module.
In this tutorial, I am specifically explaining how to write content to a text file using Python. Without importing any module, you may use the open() function and depending on the requirement
In this tutorial, I will explain how to perform certain operation on text files using Python built-in functions. The examples in the coming section shows opening a text file, reading,
This is how reduce function works: It will apply the given function of two arguments to the items of iterable e.g. a list, cumulatively.
The items of sequence are entertained from left to right and the function will “reduce” the sequence to a single value.
In this tutorial, four different ways are described with example code for how to check if a file exists or not. These methods include:
Python supports a number of ways for removing the file or directories from the specified path. Each of these ways is described below which is followed by examples.
The index function searches a list and returns the position of first matched item in the specified list. – The index starts at zero
The zip function returns an iterator of tuples that aggregates elements from each of the given iterables. For example:
The Python float function converts a given value into float. The float function takes an argument that can be a number or string with decimal point.
The int function in Python is used to convert a given value into an integer.The function returns an integer object. The object is constructed from the given string or number. If no arguments are given then it returns 0.
The bytes and bytearray are the core built-in types in Python to manipulate binary data. The bytes function returns bytes object which is immutable sequence of single bytes.
The enumerate function takes an iterable like a list, tuple etc. and returns it as an enumerate object. The function adds counter to the iterable. For example
Python makes it quite easy creating the random numbers whether it is the matter of creating random number within a range, integer numbers as well as generating floating random numbers.
In this tutorial, I will show you a few ways of copying content of one file to another by using the Python shutli module.
The shutli module has a few methods for copying the source file content into the destination file.
Python readline() method reads single line from the specified file. If used in text mode then readline() returns string and returns byte object in binary mode.