In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "what to pay attention to when using assertions in python", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what to pay attention to when using assertions in python" article.
1. Assertions are mainly for debugging assistance, for program self-test, not for handling errors.
The program BUG still depends on try. Except will solve the problem.
2. Do not use assertions to validate user input, because when python runs from the command line, if you add the-O flag, the assertion will be disabled globally and all your validation will be lost.
Example
Def something (): "" this function does a lot of operations "my_list = [] # declares an empty list # do somethingreturn my_list def func ():" call the something function to implement some logic based on the result "" ret = something () assert len (ret) = = 18, "the number of list elements is incorrect" # what can python do? Python is a programming language with many effective tools built in. Python is almost omnipotent, the language is easy to understand, easy to start, powerful, and has a wide range of applications in many fields, such as big data analysis, artificial intelligence, Web development and so on.
The above is about the content of this article on "what to pay attention to when using assertions in python". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
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.