How to realize python logical value Detection
This article introduces the relevant knowledge of "how to realize python logical value detection". In the operation of actual cases, many people will encounter such a dilemma, so 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!
Concept
1. In python, any object can detect logical values.
2. An object is treated as a real value unless when the object is called, its class is defined as the _ _ bool__ () method and returns False or defined as the _ _ len__ () method and returns zero.
A set object considered to be a false value:
Constants defined as false values: None and False.
The numeric type is zero: 0.0.0.0jleg.Decimal (0), Fraction (0jj1).
Empty sequence and multiple sets:', (), [], {}, set (), range (0)
Example
None False # constant defined false value 00.00j Decimal (0) Fraction (0,1) # Numeric type zero'() [] {} set () range (0) # empty sequence and multinomial set "how to implement python logical value Detection" is introduced here. Thank you for 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!