Python3 3 Days Quick Start-Basic Grammar and Attention

"""
 Declare a variable identifier
. The
 first character must be a letter of the alphabet or an underscore _ . The rest of the identifier consists of letters, numbers, and an underscore.
 Identifiers are case-sensitive.
 In Python 3, non-ASCII identifiers Characters are also allowed.
 Reserved words are keywords, and we cannot use them as any identifier names. Python's standard library provides a keyword module that
 can output all keywords in the current version:
 ['False', 'None' , 'True', 'and', 'as', 'assert', 'break', 'class',
 'continue', 'def', 'del', 'elif', 'else', 'except', ' finally', 'for' 'from',
 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or',
 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'
] """
 myValues ​​= "This is a declared variable"
 #This is a comment
 '''
 This is the usage of a multi-line comment
 '''
 """
 This is another way of writing a multi-line comment
 "" "
 """
The most distinctive feature of python is the use of indentation to represent code blocks without the use of curly braces {}.
The number of indented spaces is variable, but statements of the same code block must contain the same number of indented spaces. The example is as follows: 
 if True:
     print ("True")
 else:
     print ("False")
 The number of spaces in the last line of the following code is inconsistent, which will lead to a running error:
 if True:
     print ("Answer")
     print (" True")
 else:
     print ("Answer")
   print ("False") # Inconsistent indentation will cause runtime errors.
 Python usually writes a statement on one line, but if the statement is very long, we can use a backslash (\) To implement multi-line statements, for example:
 total = item_one + \
         item_two + \
         item_three
 Multi-line statements in [], {}, or () do not need to use backslashes (\), for example:
 total = ['item_one ', 'item_two', 'item_three',
         'item_four', 'item_five'
Python can use multiple statements on the same line, separated by semicolons (;), the following is a simple example:
 #!/usr/bin/python3
 import sys; x = 'runoob'; sys.stdout. write(x + ' \n ')
 blank line between
functions or between class methods are separated by blank lines, indicating the beginning of a new code. A blank line is also used to separate the class and function entries to highlight the beginning of the function entry.
Blank lines are not part of Python syntax, unlike code indentation. No blank lines are inserted when writing, and the Python interpreter runs without error. However, the role of blank lines is to separate two pieces of code with different functions or meanings, which is convenient for future code maintenance or refactoring.
Remember: blank lines are also part of program code.
"""

Guess you like

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