Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does python implement Dictionary or set derivation

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "python how to achieve dictionary or set derivation", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python how to achieve dictionary or set derivation" this article.

Dictionary / set derivation

Similar to the list derivation we use, we can also use dictionary / set derivation, which is simple and effective to use. Here is an example:

TestDict= {I: I * iforiinxrange (10)} testSet= {I * 2foriinxrange (10)} print (testSet) print (testDict) # set ([0,2,4,6,8,10,12,14,16,18]) # {0: 0,1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}

Note: only one of the two statements is different, and when the above code is run in Python3, it will be changed to.

These are all the contents of the article "how to implement dictionary or set derivation 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report