In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the compiling skills of novice Python?". In the operation of actual cases, many people will encounter such a dilemma. Then 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!
Python motto
Open the Python interactive terminal and run the following command
Then the command will have some output, read it carefully, because it is really important to Python programmers
Use this command to clear your Python interactive terminal
As you use the Python interactive terminal to test your code, there is more and more content on your screen, and slowly it starts to affect your mind, and you want to clear the previous output. The command clear on Unix-like operating systems clears the contents of the screen.
This system command can be executed using the Python standard library os.
The following line of Python command clears the contents of the Python terminal on the Unix class operating system.
The windows system can use the cls command to clear the contents of the terminal screen. Since the os library methods of Python are cross-platform and also applicable on windows, you can clear the contents of the Python interaction terminal in Python in the Windows interactive terminal like the following.
Be careful when creating tuples
Many people think that the following code will return a tuple. But it was only after the actual implementation that we knew that that was not the case at all.
After running, the Python terminal actually returns the number 1.
Based on this result, it should be easy to understand that the parentheses here do not serve as tuples, but are just simple parentheses.
What if you want a tuple with only one element? It should be like this.
Remember, always use that comma when building tuples
Test whether the variable is the correct posture of None
You might use the following code to test whether the variable is None
Don't do this. If an is 0, the if judgment can't tell you at all. The correct posture should be like this.
Get a document for a Python object
It's very easy to get the documentation for a particular method or module in the Python interactive terminal, you just need to use the help command.
Run the above command, and the interactive terminal will print out the document information of the os module, and the output will look like this
This help command is especially useful when there is no net, and it is very convenient and fast.
Of course, you can also view the documentation for a specific method in a module as follows
As you can see from the help below, the getenv method of the os module is used to get the value of the environment variable and returns None if the environment variable does not exist.
Swap the value of a variable
Exchanging the values of variables in Python is easier and intuitive than any other language.
This is the end of the content of "what are the compilation skills of novice Python". 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.