Python-Based string description and examples, pythonstring
Python string (string) Explanation and code
Python strings can be enclosed in single quotes ('), double quotation marks ("), and triple quotation marks ('''). Single quotes and double quotation marks (''') can be added, you can also add the escape sequence;
Strings are automatically connected together to form a string;
The separator R or r is added before the string, indicating that the string is a natural string. The format restrictions can be ignored;
Add "\" at the end of the physical line to connect to the next physical line. Brackets, square brackets, and braces can also expand the physical line to a certain extent;
For more information, see code comments;
The Code is as follows:
#-*-Coding: UTF-8-*-# = # File: abop. py # Author: Wendy # Date: 2013-12-03 #==============================#eclipse pydev, python3.3 # Double quotation marks ("") and single quotation marks ('') s = ''' I am a girl and like heels. hello, "python" sister. ''' # Escape Sequence "\" st = ''' Hello, girls, l like (\'''). ''' # the string is put together to automatically connect sa = 'Girls are ''' the best. '# r indicates a natural string and does not escape (\ n) sr = r "nature is good. \ n {0} "#" \ "indicates the connection string SC = 'oh, the lines are too \ large '# brackets, square brackets, and braces. the range can be limited, do not use escape print ("the braces can do {thing }. ". format (thing = "lady") print (s) print (st) print (sa) print (sr) print (SC)
Output:
the braces can do lady. I am a girl and like heels. Hello, "python" sister. Hello, girls, l like ('''). Girls are the best. nature is good. \n {0} Oh, the lines are too large
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!