In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the points for attention in compiling the Python program". In the daily operation, I believe that many people have doubts about the problems related to the preparation of the Python program. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what are the points for attention in the preparation of the Python program?" Next, please follow the editor to study!
You pick an editor just as you pick a car you will buy. A good editor will help you write Python programs easily, make your programming journey more comfortable, and help you reach your destination more quickly and safely. One of the basic requirements of the editor is the syntax highlighting function, which allows different parts of your Python program to be marked with different colors, so that you can better see your program and visualize its operation.
If you use Windows, then I suggest you use IDLE. IDLE has syntax highlighting and many other features, such as allowing you to run your program in IDLE. It is particularly worth noting that do not use Notepad-- it is a bad choice because it does not have syntax highlighting and, more importantly, it does not support text indentation.
And we will see that text indentation is extremely important to us. A good editor, such as IDLE (and VIM), will automatically help you do these things. If you use Linux/FreeBSD, you have many options. If you are an experienced programmer, you must already be using VIM or Emacs.
There is no doubt that they are two large editors with * functions. Use them to write your Python programs, and you will benefit from them. I personally use VIM to write most of my programs. If you are a beginner programmer, you can use Kate, which is also one of my favorite editors.
As long as you are willing to take the time to learn to use VIM or Emacs, I strongly recommend that you learn either of them, because they are extremely helpful to you in the long run. Now let's start programming again. When you learn a new programming language, it has become a tradition that the programs you write and run are usually "Hello World" programs.
When you run the "Hello World" program, all it does is say "Hello World". As Simon Cozens, who proposed the "Hello World" program, said: "it is the traditional mantra of the god of programming and can help you learn the language better."
To run this program, open shell (Linux terminal or DOS prompt) and type the command python helloworld.py. If you use IDLE, use the menu Edit- > Run Script or use the keyboard shortcut Ctrl-F5. The output is shown below.
$python helloworld.py Hello World
If you get the same output as shown above, congratulations! You have successfully run your Python program. In case you get an error, make sure the program you typed is correct, and then run the program again.
Note that Python is case-sensitive, that is, print is different from Print-- notice that the first is lowercase p and the second is uppercase P. Also, make sure there are no spaces or tabs before the opening character of each line-- we'll discuss why this is important later.
How it works: let's think about the first two lines of the program. They are called comments-anything to the right of the # symbol is a comment. Comments are mainly used as notes for program readers. The Python should have at least a special form of comment like the * * line. It is called the organization line-the first two characters of the source file are #!, followed by a program.
This line tells your Linux/Unix system which interpreter it should run when you execute your program. This will be explained in more detail in the next section. Note that you can always run your program on any platform by specifying an interpreter directly on the command line. It's like ordering python helloworld.py.
Use annotations properly in your program to explain some important details-this will help your program's readers easily understand what the program is doing. Remember, this reader may be you in 6 months!
The comment is followed by a Python statement-- it just prints the text "Hello World". Print is actually an operator, and "Hello World" is called a string-- don't worry, we'll explain these terms in more detail later.
At this point, the study on "what are the points for attention in compiling Python programs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.