In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "what are the little-known features of python". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the little-known features of python.
Subtle string > a = "wtf"
> b = "wtf"
> an is b
True
> a = "wtf!"
> b = "wtf!"
> an is b
False
> A, b = "wtf!", "wtf!"
> an is b
The result returned by True # 3.7is False. Unexpected "is" > a = 256
> b = 256
> an is b
True
> a = 257
> b = 257
> an is b
False
A = 257; b = 257
> an is b
True said that the tuple is immutable. Some_tuple = ("A", "tuple", "with", "values")
Another_tuple = ([1,2], [3,4], [5,6])
> some_tuple [2] = "change this"
TypeError: 'tuple' object does not support item assignment
> another_tuple [2] .append (1000) # No error occurs here
> another_tuple
([1,2], [3,4], [5, 6, 1000])
> another_tuple [2] + = [99999]
TypeError: 'tuple' object does not support item assignment
> another_tuple
([1, 2], [3, 4], [5, 6, 1000, 9999]) vanishing global variable e = 7
Try:
Raise Exception ()
Except Exception as e:
Pass
Output
> > print (e)
NameError: which value def some_func () is returned when name 'e'is not definedtry encounters finally:
Try:
Return 'from_try'
Finally:
Return 'from_finally'
Output
> > some_func ()
From_finally' at this point, I believe you have a deeper understanding of "what are the little-known features of python?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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: 249
*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.