In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "where can Python programs be written". In the operation of actual cases, many people will encounter such a dilemma. Next, 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!
Interactive environment of tools for writing code
We open Windows's command prompt tool, enter the command python and enter to enter the interactive environment of Python. The so-called interactive environment is that when we enter a line of code, the code will be executed immediately, and if the code produces a result, then the result will be displayed in the window. For example:
Python 3.7.6
Type "help", "copyright", "credits" or "license" for more information.
> 2 * 3
six
> 2 + 3
five
Warm reminder: users using the macOS system need to open the "terminal" tool and enter python3 to enter the interactive environment.
If you want to exit the interactive environment, you can enter quit () in the interactive environment, as shown below.
> > quit ()
Text Editor-Visual Studio Code
Visual Studio Code (usually referred to as VS Code for short) is a code editing artifact developed by Microsoft that runs on operating systems such as Windows, Linux, and macOS. It supports a series of convenient functions, such as syntax highlighting, automatic completion, multipoint editing, running and debugging, and can support a variety of programming languages. At this stage, I strongly recommend that you use VS Code to write Python code. About the download, installation and use of VS Code, we recommend that you read the article entitled "VScode installation and use" on Zhihu. The following figure shows the main user interface using VS Code.
Integrated development environment-PyCharm
If you use Python to develop commercial projects, we recommend that you use the professional tool PyCharm. PyCharm is an integrated development environment (IDE) for Python development developed by the Czech company JetBrains. The so-called integrated development environment means that this tool provides various functions such as code writing, code running and debugging, code analysis, code version control, etc., so it is especially suitable for the development of commercial projects. The PyCharm download link is provided on the official website of JetBrains, in which the community version (Community) is free but relatively weak, and the professional version (Professional) is very powerful, but it needs to be used for an annual or monthly fee, and new users can try it for 30 days. We will explain how to use PyCharm for Python development in a later course.
Hello, world
According to the practice of this industry, the first program we learn to write in any programming language is to output hello, world, because this code is the first code written by the great Dennis Ritchie (inventor of the C language) in his immortal book The C Programming Language.
Print ('hello, world')
Run the program
It is recommended that you use VS Code to write the above code, after editing the code, save the code to the user's home directory, it is recommended that you name the file hello.py. The user's home directory is a folder with the same name as the user name you used to log in to the system. For example, if you use the name Administrator when you log in to the Windows system, the name of the user's home directory is also Administrator. For Windows users, you can set up to display the user home directory on the desktop, so that you can easily find this folder; if there is no user home directory on the desktop, you can find the folder named Users or user in the C file name, where your user home directory is located.
After saving your code, you can open the command prompt tool. The command prompt tool usually sets the user's home directory to the default work path. At this time, you can enter a dir command to see if you can see the hello.py file you just saved. If you find this file, you can execute the following command to see if hello and world are output on the screen.
Python hello.py
Again: if you are using a macOS system, you need to run the program through the python3 hello.py command.
You can try to replace the hello and world in the single quotation marks of the above program with something else, or you can try to write a few more print (preferably only one per line) to see what happens.
Comment your code
Comments are an important part of the programming language, which is used to explain the role of the code in the source code to enhance the readability of the program. Of course, we can also remove the code snippets from the source code that do not need to be run for the time being through comments, so that we can remove the comment symbols when the code is needed. In a nutshell, comments make the code easier to understand without affecting the execution of the program.
00001. Single-line comments-parts that begin with # and spaces can comment out an entire line of code.
00002. Multiline comments-begins with three quotation marks and ends with three quotation marks, usually used to add large pieces of descriptive content.
"
The first Python program-hello, world
Salute to the great Mr. Dennis M. Ritchie
Version: 0.1
Author: Luo Hao
"
Print ('hello, world')
# print ("Hello, World!")
This is the end of the content of "where can Python programs be written". Thank you for your 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.