How does python implement Dictionary or set derivation
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!