In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Python function". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Python function".
Variable assignment
Just like the functions * args and * * kwargs, you can use the same syntax in variable assignments:
Merge two dictionaries
Use the * * kwargs syntax in the iterable variable assignment method when merging dictionaries:
Be careful that if there is a common key between dictionaries, the latter key-value pair (in y) will replace the former. According to the latest Python release (3.9), a whole new syntax can be used to avoid this problem, that is, dictionary merging and updating operators:
Z = x | y # merge-behavior pattern described above
X | = y # Update-replace dictionary merge
Immutable set
In Python, you can use collections, that is, unordered collections of different objects. These sets are mutable, meaning that transformations can be done with add () and remove ()-- which means that variable sets are not hashable.
Instead, you can use the immutable set frozenset (), a set that cannot change its value. But because it's immutable, it's hashable-- this is true when you use set and frozenset as dictionary keys at the same time:
Using frozenset as a dictionary key does not seem practical, but the role of frozenset is to provide more detailed and purposeful code. This reminds future code readers that if you change me, everything will fall apart.
Multi-factor condition
Clean up those messy if statements instead of:
If 0
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.