{"id":2962,"date":"2023-10-17T10:30:13","date_gmt":"2023-10-17T05:00:13","guid":{"rendered":"https:\/\/python-programs.com\/?p=2962"},"modified":"2023-11-10T11:43:46","modified_gmt":"2023-11-10T06:13:46","slug":"basics-of-python-string","status":"publish","type":"post","link":"https:\/\/python-programs.com\/basics-of-python-string\/","title":{"rendered":"Basics of Python \u2013 String"},"content":{"rendered":"
In this Page, We are Providing Basics of Python \u2013 String. Students can visit for more Detail and Explanation of Python Handwritten Notes<\/a>\u00a0Pdf.<\/p>\n String<\/strong><\/p>\n Python can manipulate string, which can be expressed in several ways. String literals can be enclosed in matching single quotes (‘) or double quotes (“); e.g. ‘hello’, “hello” etc. They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple- quoted strings), e.g. ‘ hello ‘, “hello”. A string is enclosed in double-quotes if the string contains a single quote (and no double quotes), else it is enclosed in single quotes.<\/p>\n The above statements can also be written in some other interesting way using escape sequences.<\/p>\n Escape sequences are character combinations that comprise a backslash (\\) followed by some character, that has special meaning, such as newline, backslash itself, or the quote character. They are called escape sequences because the backslash causes an escape from the normal way characters are interpreted by the compiler\/interpreter. The print statement produces a more readable output for such input strings. Table 2-12 mentions some of the escape sequences.<\/p>\nBasics of Python \u2013 String<\/h2>\n
>>> \"doesnt\"\r\n'doesnt'\r\n>>> \"doesn't\"\r\n\"doesn't\"\r\n>>> '\"Yes,\" he said.'\r\n' \"Yes., \" he said. '<\/pre>\n
>>> \"doesn\\' t\" ;\r\n\"doesn ' t\u201d\r\n\u2018>>> '\\\"Yes,\\\" he said.'\u00a0\r\n' \"Yes,\" he said.'<\/pre>\n