| by Arround The Web

XOR Two Strings in Python

The “ord()” function converts string values into their ASCII representatives and passes to XOR. “^” operator returns the difference of converted ASCII values.

Share Button
Read More
| by Arround The Web

Input Function in Python: Concepts and Examples

Learn how to get the input function in Python to accept values from standard input and how to process them.
The post Input Function in Python: Concepts and Examples appeared first on Linux Today.

Share Button
Read More
| by Arround The Web

Sort Nested List in Python

In Python, “sort()” and “sorted()” methods sort a nested list in ascending, descending order, based on the index of a tuple or with respect to length.

Share Button
Read More
| by Arround The Web

How to Get Return Code From Process in Python Subprocess Execution?

Use the “returncode” attribute, “communicate()”, or the “check_output” method to get the return code from a process in Python subprocess execution.

Share Button
Read More
| by Arround The Web

Python Extract Substring Using Regex

The “re.match()”, “re.search()”, “re.findall()”, and “re.finditer()” methods of the “re” module are used for extracting substring using regex in Python.

Share Button
Read More
| by Arround The Web

How to Read Pickle File Python?

To read the pickle file in python, use the “load()” method from the pickle package or alternatively use the “read_pickle()” method from the pandas package.

Share Button
Read More
| by Arround The Web

Python Create File If Not Exists

To create a file after checking its non-existence in Python, use the open() method with the “w+” flag or use the pathlib module.

Share Button
Read More
| by Arround The Web

Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2

The post Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2 first appeared on Tecmint: Linux Howtos, Tutorials & Guides .In the previous article of this Python series, we shared a brief introduction to Python, its command-line…

Share Button
Read More
| by Arround The Web

Getting Started with Python Programming and Scripting in Linux – Part 1

The post Getting Started with Python Programming and Scripting in Linux – Part 1 first appeared on Tecmint: Linux Howtos, Tutorials & Guides .It has been said (and often required by recruitment agencies) that system administrators need to be proficient…

Share Button
Read More
| by Arround The Web

Python Pad a String with Leading Zeros

To pad the string with leading zeros in Python, the “f-string“, “format()”, “zfill()”, “rjust()”, and “ljust()” methods can be used.

Share Button
Read More
| by Arround The Web

Python Add String to List

To add the string to the list, the “+” operator, the “insert()” method, the “extend()” method, and the “itertool.chain()” method can be used.

Share Button
Read More
| by Arround The Web

Python Inline If-else

The inline if-else is a logical statement that allows users to preserve the code quality in a single line by replacing the number of lines of “if-else” code.

Share Button
Read More
| by Arround The Web

Python Prepend List

To prepend the Python list, the “+” operator with square brackets “[ ]”, “slicing” method, “insert()“ method and “deque.appendleft()“ method can be used.

Share Button
Read More
| by Arround The Web

Pip Install Tkinter

The pip install tkinter command is used to install the tkinter package, a GUI building tool, in your Python Environment. Read this guide to learn about Tkinter.

Share Button
Read More
| by Arround The Web

Python Substring After Character

To get substring after a character in Python, the “split()” method, the “partition()” method, the “index()” and the “find()” method are used.

Share Button
Read More
| by Arround The Web

Python Check if a String is a Float

To check if a string is float or not in Python, the “float()” method, the “replace()” method and the “isdigit()” method are used.

Share Button
Read More
| by Arround The Web

Python Truncate String

Truncating a string means splitting the string into separate parts. In Python, truncating a string can be done by slicing and by using the rsplit() method.

Share Button
Read More
| by Arround The Web

Python Insert Character Into String

Use the concatenation operator (+) to add the character(s) at either end of the string, or use the string slicing to insert them into the middle of the string.

Share Button
Read More
| by Arround The Web

Python KeyboardInterrupt

The Python KeyboardInterrupt is the action performed by the user by pressing the combination “CTRL + C” terminating the execution of the program.

Share Button
Read More
| by Arround The Web

Overwrite a file in Python

Python has several methods for overwriting files such as the “write()” method, the “truncate()” method, the mode “w”, “shutil” module, or the “os” module, etc.

Share Button
Read More