For example: ' String ', ' string ', ' ' ' ', ' ' ' ', ' ' or ' string '.
In use, there is no difference between single and double quotes. The main function of the three quotation marks is to include line breaks in the string. That is, the string in the three quotation marks, if the contents of which are branches in the program, then in use is also a branch. This will not need to display the use of "\ n" to break the line.
Like most programming languages, strings in Python are immutable. Similarly, the handling of transferred characters is similar to other languages. such as "What ' s your name? ' "Within this string, there is a" ' "character, and for this character, you can use the ' \ ' character transfer: ' what\ 's your name ', or use double quotes instead of a string definition:" What's your name? ". The usual way is to use ' \ ' to transfer characters. You can use ' \ n ' to define a newline, ' \ t ' indicates a tab, ' \ \ ' represents a real ' \ ' character.
For strings, there is a very useful format method. The main purpose of this method is to replace the ugly "+" string connection. For example, "My name is {0}". Format ("un"), then the true value of this string is "my name is United Nations". This allows you to replace the contents of this string at run time. You can also replace it with a named parameter, for example: "My name is {name}". Format (name= "un").
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service