Python Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16|Last
Lessons:-INTRODUCTION

1.8. Strings Part II
1.8.1. Triple Quoted String Literals. Strings delimited by one quote character are required to lie
within a single Python line. It is sometimes convenient to have a multi-line string, which can be delimited
with triple quotes: Try typing the following. You will get continuation lines until the closing triple quotes.
Try in the Shell:
sillyTest = ’’’Say,
"I’m in!"
This is line 3’’’
print(sillyTest)
The line structure is preserved in a multi-line string. As you can see, this also allows you to embed both
single and double quote characters!
1.8.2. Escape Codes. Continuing in the Shell with sillyTest, enter just
sillyTest
The answer looks strange! It indicates an alternate way to encode the string internally in Python using escape
codes. Escape codes are embedded inside string literals and start with a backslash character (\). They are
used to embed characters that are either unprintable or have a special syntactic meaning to Python that
you want to suppress. In this example you see the most common ones:
Escape code Meaning
\’ ’
\n newline
\\ \
The newline character indicates further text will appear on a new line when printed. When you use a
print function, you get the actual printed meaning of the escaped coded character.
Predict the result, and try in the Shell:
print(’a\nb\n\nc’)
Did you guess the right number of lines splitting in the right places?

 
 
 
image
Anil  Bist

Skills    Python

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)