In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to deeply analyze the features of Python language. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
The special rules and details of python are not covered here, and the goal is to give you a quick understanding of the features of the Python language through examples. The basic concepts of variables, expressions, control flow, functions and input / output are briefly introduced. The advanced features of Python language are not covered in this chapter.
The Python program is executed through the interpreter. If your machine already has python installed, simply type python on the command line to run the python interpreter.
When the interpreter is running, there will be a command prompt >. Type your program statement at the prompt, and the typed statement will be executed immediately. In the following example, we type the most common command that displays "Hello World" after the > > prompt:
1 class Stack (object): 2 def _ init__ (self): # initialization stack 3 self.stack = [] 4 def push (self Object): 5 self.stack.append (object) 6 def pop (self): 7 return self.stack.pop () 8 def length (self): 9 return len (self.stack)
Under Windows, you can execute the python program simply by double-clicking a .py file. Windows automatically invokes the python interpreter and then launches a terminal window (DOS-like window) to execute it. In this case, the terminal window closes immediately after the program has been executed (often before you see its output). To avoid this problem, you can use the python integrated development environment.
Such as IDLE or Pythonwin. Another possible way is to create a bat file and write such a line of statements in the file, such as python-I helloworld.py. Run this batch, and the program automatically enters the python interpreter after execution. In the interpreter, you can also run a program saved on disk through the function execfile (), as in the following example:
Toggle line numbers Toggle line numbers 1 s = Stack () # Create a stack (create) 2 s.push ("Dave") # Push some things onto it (write) 3 s.push (42) 4 s.push ([3jue 4jue 5]) 5 x = s.pop () # x gets [3Jing 4 5] (read) 6 y = s.pop () # y gets 42 7 del s # Destroy s (delete)
This statement evaluates the value of the expression and assigns the result to the principal variable as its new value. When the assignment occurs, the value 1000 that principal originally bound is discarded. When the assignment ends, not only does the value of the principal binding change, but its type also changes with the assignment action.
In this example, because rate is a floating-point number, principal becomes a floating-point number after the assignment is complete. The while statement first checks the loop condition after it, and if the conditional expression is true, it executes the statement block after the colon, and then tests the loop condition again until it is false.
The abbreviated statement block after the colon is a circular body. Note that the Python language uses indented blocks to represent program logic (most other languages use curly braces, etc.). The three statements after the while statement in Listing 1.1 are loop bodies and are executed in each loop.
The above is the editor for you to share how to deeply analyze the characteristics of Python language, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.