Python Escape Characters

Python Escape Characters Table Escape Character Explanation \’ Single Quote \” Double Quote \n Newline Character \t Tabular Character \b Backspace Character \r Carriage Return \\ Backslash \ Form Feed \ooo Octal Value \xhh Hex Value Examples The following examples show the working of the different escape characters in a Python context. We provide the … Read more

Python Print Without Quotes

Problem Formulation In Python’s interactive mode, each line is assumed to be an expression that is evaluated. The return value is provided to the user. Thus, if you evaluate a string expression or call a function or an operation that returns a string, the output will display quotes around the string to tell the user … Read more

How to Serialize a Python Dict into a String and Back?

Problem Formulation Given a Python dictionary containing lists and other data structures. You want to store the dictionary in a file or send it over the network in a more efficient form. How to serialize a Python dictionary into a string, and then deserialize the string back to a dictionary data structure? Here’s a rough … Read more

How to Get the Substring of a String in Python?

To get a substring of a given string in Python, you can use a popular feature called “slicing“. The syntax is string[start:stop:step] with the following meaning: start is the index of the first character included in the substring, stop is the index of the last character, but it is not itself included in the substring, … Read more