In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to understand python tuples". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to understand python tuples" together!
directory
1. Unpacking
2、enumerate
3、list()
A tuple is an immutable sequence that cannot be modified once created.
1. Unpacking
Take the elements of a tuple and assign them to different variables
>>> a = ('hello', 'world', 1, 2, 3)>>> str1, str2, n1, n2, n3 = a>>> str1'hello'>>> str2'world'>>> n11>>> n22>>> n33>>> str1, str2, *n = a>>> str1'hello'>>> str2'world'>>> n[1, 2, 3]>>> str1, _, n1, n2, _ = a2、enumerate
Explanation: used for tuple traversal, get tuple object, the first element is index, the second is numeric
a = ('1', 2, 35, 'hello')for i in enumerate(a): print(i)>>> (0, '1')>>> (1, 2)>>> (2, 35)>>> (3, 'hello')3、list()
Tuples converted to lists
Pythona =('1 ', 2, 35, ' hello') print(list(a))>> ['1', 2, 35, ' hello'] Thank you for your reading. The above is the content of "How to understand python tuples". After studying this article, I believe you have a deeper understanding of how to understand python tuples. The specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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.