[6. Comments and quotation marks]] Zero basic learning of python, simple and rude

comment quotes

Commenting in python is the same as in other languages, the commented part will not be used by the program

  • single-line comment, multi-line comment
  • Single-line comments are usually preceded by #
    # here is a single line comment

     

  • Multi-line comments include single, double, and triple quotes
        sentence = ' I am a single quote, when used alone, I am no different from a double quote '
        print(sentence)
    
        sentence = " I am double quotes. When used alone, I am no different from single quotes "
        print(sentence)
    
        # Only double quotes can be nested within single quotes
        sentence = " Chairman Mao once said: 'All reactionaries are paper tigers' "
        print(sentence)
    
        # Only single quotes can be nested within double quotes
        sentence = ' Deng Xiaoping once said: "A black cat is a white cat, if it can catch mice, it is a good cat" '
        print(sentence)
    
        # The format of triple quotes will be preserved when printing
        sentence = '''
             a good poem
        Ocean, you are all fucking water,
        Spider, you're all fucking legs,
        Chili is so fucking hot,
        I fucking regret not learning Python.
                ——Nicholas Zhao Si, the Asian dance king
        '''
        print(sentence)

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325623237&siteId=291194637