In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how Python code has been written and how it works. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Python interactive command line
(1) what is the command line?
The command line generally refers to the command prompt, that is, a working prompt that prompts for command input in the operating system. Command prompts vary from operating system to operating system. For example, in the windows environment, the command line program is cmd.exe, which is a 32-bit command line program. When something like "C:\ >" appears, it is in the command line mode provided by Windows.
(2) what is an interactive command line?
To put it simply, the appearance of "> >" is python's interactive command line learning how to use the interactive command line is the first step in learning Python. The Python command line is interactive and friendly. If you type a statement to execute, it will immediately give you the result of executing the statement.
(3) run Python code
In the cmd window, enter python and enter the python interactive command line. Enter the code directly:
Print'hello worldview'
If you can see the running results on the interface, it means that the run is successful!
(4) Analysis of advantages and disadvantages.
Interactive interpreter is a good tool for learning Python language. The advantage is that input Python statements can get feedback immediately. If you write a program on the interactive command line in Python, you can get the results at once, but the downside is that you can't save it. You have to type it again the next time you want to run it. Therefore, in actual development, we always use a text editor to write Python code, and then save it as a file, so that the program can be run repeatedly.
2. Use a text editor
We have to first put "hello world!" The program is written in a text editor, saved, and named. Here we name it hello.py and save it to F:\ workspace. When naming, it is important to note that the file name can only be a combination of letters, numbers and underscores. Then in command line mode, type python F:\ workspace\ hello.py to run successfully. When running, you should note that the python file storage path is a relative path, and at run time, be sure to specify the storage path of the python file, otherwise an error will be reported.
Of course, if you want to run Python code, you can also open an interactive command window while writing code in a text editor and glue some of the code to the command line to verify.
Thank you for reading! This is the end of this article on "how to write Python code". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.