In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what are the differences between is and = = in python". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are the differences between is and = = in python".
=-> values on both sides of the comparison.
Is- > the memory address of the comparison, check it with id ().
Small data pool ☆☆☆
Numeric small data pool range-5cm 256 (within this range, different variables are assigned the same value and their memory addresses are equal)
If there are special characters in the string, their memory addresses are different.
Within a single character * 20 in a string, their memory addresses are the same, while those above * 21 are different.
Note: the above can only be tested on the terminal, but cannot be run in pycharm, because pycharm defaults to True, and when the terminal exceeds the above condition, it is False.
Practice
N = 10
N1 = 10
Print (n = = N1)
# id () check the memory address
# all data types have memory addresses
# is to check memory address
Print (id (n))
Print (n is N1) # True
# string
A = 'alex'
B = 'alex'
Print (an is b) # True
# list
L1 = [1pm 2pm 3]
L2 = [1, 2, 2, 3]
Print (L1 is L2) # False
# tuple
Tu = (1, 2, 3)
Tu1 = (1, 2, 3)
Print (tu is tu1) # False
# Dictionary
Dic = {'name':'alex'}
Dic1 = {'name':'alex'}
Print (dic is dic1) # false
# tuple
Tu = (1, 4, 4, 6)
Tu1 = (1, 4, 4, 6)
Print (tu is tu1) # False
# Mini datapool-5 '256
N =-10000
N1 =-10000
Print (n is N1) # False, running in pycharm beyond the small data pool is also True
A = 10000
B = 10000
Print (id (a), id (b))
The above is all the content of the article "what's the difference between is and = = in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.