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 mainly introduces "what is the method of getting started with Python". In daily operation, I believe that many people have doubts about the method of getting started with Python. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is the method of getting started with Python?" Next, please follow the editor to study!
1.Hello world
After installing Python, open IDLE (Python GUI), which is the Python language interpreter, and the statements you write can be run immediately.
Let's write a famous program sentence:
Press enter, and you can see this famous saying introduced into the program world by Khamr.
Select "File"-- "New Window" or the shortcut key Ctrl+N in the interpreter to open a new editor.
Write the following statement:
Save as an a.py file.
Press F5 and you can see the result of the program.
This is the second way to run Python.
Find your saved a.py file and double-click to see the results of the program.
Python programs can be run directly, which is an advantage over Java.
two。 International support
We greet the world in a different way. Create a new editor and write the following code:
When you save the code, Python will prompt you whether to change the character set of the file. The result is as follows:
Change the character set to a form we are more familiar with:
The program also works well.
3. A convenient calculator
It is too troublesome to count with the calculator that comes with Microsoft. Open the Python interpreter and calculate directly:
4. String, ASCII and UNICODE
You can print a string in a predefined output format as follows:
How is the string accessed? Look at this example:
Note the difference between ASCII and UNICODE strings:
5. Use List
Similar to List in Java, this is an easy-to-use data type:
6. Conditional and loop statements
7. Define function
Also, introduce a function that is convenient to use:
8. File IZP O
9. Exception handling
10. Classes and inheritance
11. Packet mechanism
Each .py file is called a module,module that can be imported into each other. Please refer to the following example:
So how does Python find the module we define? In the standard package sys, the path attribute records the package path of the Python. You can print it out:
Usually we can put the package path of module into the environment variable PYTHONPATH, which is automatically added to the sys.path attribute.
Another convenient way is to programmatically specify our module path directly to sys.path:
At this point, the study on "what is the method of getting started with Python" 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.