Episode of string variables and review exercises +

## episodes of variable
           ※ variable name as the name of our social reality, when a value is assigned to the name, Ta will be stored in memory, called the variable (variable), in most languages, regarded this behavior is called "variable assignment" or "the value stored in the variable."

           ※ But the practice of most other computer languages ​​Python is slightly different, Ta is not the value stored in a variable, but rather the name attached to the upper value.

           ※ So some Python programmers would say, "Python" no "variable" only "name."

Local ## Note
           ※ Before using a variable, you need to first assignment.

           ※ variable names can include letters, numbers, underscores, but the variable name can not start with a number.

           ※ letters can be uppercase or lowercase, but the case is different. That fishc two and FishC for Python is completely different names

           ※ equal sign (=) is the assignment of meaning, is the name of the left, the right is the value, and write anti-cough.

           ※ theory of naming variables can take any legal name, but as a good programmer, please try to get the name of a professional and a little to the variable:
            <<< t = 'small turtles'
            <<< xxoo =' small turtle '
            <<< Teacher =' small turtle '(this has meaning only professional assignment))

## episode of string
           ※ So far, we perceived the string is everything in quotation marks, we also called the string of text, text and numbers are very different, we look at an example:
            <<< 5+ 8
          Here Insert Picture Description
            <<< '5' + '8'
          Here Insert Picture Description
           ※ to tell Python you create a string, we must put quotation marks around character, can be single or double quotes, Ms. Python said they did not picky. But it must be in pairs, while you can not single quotes, but efforts to reach the other side to spend the end of the double quotes.

           ※ If you need single or double quotation marks appear in a string how to do? For example, I want to print a string: Let's go!

           ※ There are two ways, first a relatively common, is to use our escape character (\) to escape quotation marks in a string:
            ! <<< 'Let \' S Go '

          Here Insert Picture Description
          Here Insert Picture Description

           ※ There is also a method of small turtles secrecy, let us first think about the after-school exercise inside there will be an example to explain.

## original string
           ※ like the backslash is a good thing, but try to print:
            <<< str = 'C: \ now'
          Here Insert Picture Description

            (You can see the output with print \ n resolves to wrap up)

           ※ We can itself be escaped with a backslash:
            <<< str = 'C: \ now'
          Here Insert Picture Description

           ※ But if there is a lot for a backslash in a string:
            <<< str = 'C: \ Program Files \ Intel \ the WiFi \ Help'

           ※ original string is very simple, just in front of the string plus a letter to r:
            <<< str = r'C: \ now '
          Here Insert Picture Description
            (will automatically help you add \ slash escaped, but in the end add \ slash syntax error occurs, the exercises will be solved)
          Here Insert Picture Description

## long string
           ※ If you want to get a string across multiple lines, such as:
            I love fish C,
            as I love little turtle,
            his gung ji gung ji
            gung ji gung ji
            gung ji gung ji's voice
            always wrapped around me mind,
            a long time refused to disperse ......
           ※ this we need to use a triple-quoted string!
          Here Insert Picture Description
## of refresher exercises

           0. If you have to enter a back slash at the end of the original string, how can flexibility?
Here Insert Picture Description

Published 150 original articles · won praise 70 · views 50000 +

Guess you like

Origin blog.csdn.net/w15977858408/article/details/104038781