For example, 'string', "string", "" string ", or '''string '''.
There is no difference between single quotes and double quotes. The main function of the three quotation marks is to include line breaks in strings. That is to say, if the content in the string is ProgramIf it is a branch, it is also a branch in use. In this way, you do not need to use "\ n" to wrap the line.
Like the majorityProgramming LanguageSimilarly, strings in Python are unchangeable. Similarly, Transfer Character Processing is similar to other languages. For example, "What's your name? '", The character"' "appears inside the string. For this character, you can use '\' to transfer: 'What \'s your name? ', Or use double quotation marks instead of string definition: "What's your name? ". It is often used to transfer characters using. You can use '\ n' to define a line break.' \ t' indicates a tab, and '\' indicates a real '\' character.
There is a very useful format Method for strings. The main purpose of this method is to replace the ugly "+" string connection. For example, "My name is {0}". Format ("United Nations"), the true value of this string is "My name is United Nations ". In this way, you can replace the content of this string at runtime. You can also replace it with a named parameter, for example, "My name is {name}". Format (name = "").