In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "indentation of python grammar and escape of characters". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Indentation of a statement
The biggest difference between python and programming languages such as java and c is that instead of using curly braces {} in python syntax, it uses indentation to represent blocks of code. This makes the code more concise and won't make an error by writing one less curly braces.
Python does not specify the use of several spaces for indentation, but generally uses a tab key (that is, four spaces) to indicate indentation. It is important to note that the statements in each block of code must contain the same number of indented spaces, otherwise an error will be reported.
# correct writing if True: print ("true") else: print ("false") # incorrect writing if True: print ("true") print ("yes") else: print ("false") print ("no") # indentation is inconsistent, which will cause incorrect comments to run
Single-line comments in python begin with #, and anything that is commented out is ignored and not output. In order to standardize the code, usually the # pound sign needs to be followed by a space.
# this is a comment
Multiline comments can use single quotation marks or three double quotation marks. Note that single or double quotation marks must be single or double quotes in English and must appear in pairs.
'' one comment, two comments''"one comment, two comments"identifier
Identifiers consist of letters, underscores, and numbers, and cannot start with a number. The first character must be a letter in the alphabet or an underscore _.
Note: identifiers in python are case sensitive
Keyword
Some python markers with special functions are the so-called keywords. Keywords are already used by python, so developers are not allowed to define identifiers with the same names as keywords, that is, keywords cannot be used as identifiers
And as assert break class continue def delelif else except exec finally for from globalif in import is lambda not or passprint raise return try while with yield character escape
Like many programming languages, backslash\ plus characters are automatically escaped, and if you want to print as-is characters, add a backslash\, two backslashes plus characters.
Escape character meaning ASCII code value (decimal)\ a ring (BEL) 007\ b backspace (BS), move the current position to the previous column 008\ f page feed (FF), move the current position to the beginning of the next page 012\ nnewline (LF), move the current position to the beginning of the next line 010\ r enter (CR) Move the current position to the beginning of the line 013\ t horizontal tabulation (HT) (skip to the next TAB position) 009\ v Vertical tabulation (VT) 011\ represents a backslash character'\ 092\ 'represents a single quotation mark (apostrophe) character 039\ "represents a double quote character 034\? Represent a question mark 063\ 0 empty character (NUL) 000\ ddd1 to any character represented by 3-digit octet\ xhh1 to any character represented by 2-bit hexadecimal "indentation and character escape usage of python syntax" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.