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)05/31 Report--
This article introduces the relevant knowledge of "analysis of the use of operators in python". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Comparison operator
Comparison operators are mainly True and Fals two values
number
comparison operators
description
1
==
equal to
2
!=
Python 3 is no longer used.
not equal to
3
>
greater than
4
=
greater than or equal to
6
b))#Less than or equal to print ('a and b equal to comparison value: '+str(a=b))#Less than or equal to print ('a and b equal to comparison value: '+str(a>2))
The effects are as follows:
IV. Logical operators
number
logical operators
description
1
and
And operators, a and b are True only if they are True
2
or
Or operators, a and b where one is True, then True
3
not
No operator, a is False, then True
The code is as follows:
a=len(str(51))0print ('a value:'+ str(a))print ('b value:'+ str(b))#and operator if True:print ('a and b value:'+ str(a and b))#or operator if True:print ('a or b value:'+ str(a or b))# a non-operator if True:print ('not (a) value:'+ str(not(a)))
The effect is as follows:
V. Member operators
number
member operator
description
1
in
a in b returns True
2
not in
a is not in b, returns True
The code is as follows:
a='C'b=[5,1,'C',' T','O'] print ('a value:'+ str(a))print ('b value:'+ str(b))# in operator if True:print ('a in b value:'+ str(a in b))# not in operator if True:print ('a not in b value:'+ str(a not in b))
The effect is as follows:
member operator
number
member operator
description
1
is
If a and b are the same, return True.
2
is not
A and B are not the same, returns True
The code is as follows:
a='C'b=[5,1,'C',' T','O'] print ('a value:'+ str(a))print ('b value:'+ str(b))# in operator if True:print ('a in b value:'+ str(a in b))# not in operator if True:print ('a not in b value:'+ str(a not in b))#!/ usr/bin/python3# -*- coding: utf-8 -*-# Feb 12, 2022 11:00 AMa='51CTO 'b=' 51CTO'print ('a value:'+ str(a))print ('b value: '+str(b))# is operator if True:print ('a is b Value:'+ str(a is b))# is not Operator if True:print ('a is not b-value:'+ str(a is not b))# is operator, clearing spaces a=a.strip()b=b.strip()if True:print ('a is b-value:'+ str(a is b))# is operator, clearing spaces c='51CTO'd ='51CTO'if True:print ('c is d-value:'+ str(c is d))
The effects are as follows:
"Python operators use example analysis" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.