Strings in Python programming language

The lines belong to the list of basic data types, virtually any programming language. Python is no exception. For the writing of software quality and comfortable work you'll have to explore all the subtleties of working with this type of data, and should start with the basics!

First we need to learn how to create a string. To create a string in Python version 3 uses quotation marks (""). Use single quotes are also permitted ( ''). In the derivation of the console string is enclosed in single quotes. Also, please note that transfers in the writing lines are not taken into account. For ease of understanding, it is worth considering the following example in the Python console:

Input:

"Hi, I'm a string in double quotes"

'Hi, I'm a string in single quotes'

In the derivation of the information presented strings are enclosed in single quotes.

The big drawback of rows is that the ability to display any character on the screen is not, since it results in an error. To display a specific list of characters you want to use a backslash (\). To this list of characters include the above quotes. Consider the following example:

Input:

"He \'s brother so tired"

In this case, the backslash is used to display an apostrophe.

To go to a new line, you can use two ways: sign-separator \ n or triple quotation marks (that is, enter the string in the """...""" or '''...'''). When using triple quotation marks \n placed automatically in the place of transfer and its application is not required.

Now you have learned to work with strings, and you can start writing programs, entry-level!


28 February 2017

You may be interested in

11 October 2023
Installing MikroTik RouterOS on a VPS-N server running ...
RouterOS is the operating system on which MikroTik equipment runs. RouterOS can also be installed on ...
27 September 2023
Your own VPN Outline? Easily!
We are sharing the easiest way to install VPN Outline using ubuntu 20.04 as an example.