Which one of the following is better to use and why?
Method 1:
For , in os.environ.items (): Print "% s =% s"% (k, v)
Method 2:
Print "\ n". (("% S =% s" for% k (k, v), o os.environ.items ()])
I look forward to the way forward I can, but this can only be because I am new to the dragon and the understanding of the list is still something foreign to me. Is the second method considered to be more phenomenal? I am assuming that there is no performance difference, but I could be wrong.What would be the advantages and disadvantages of these 2 techniques?
(taken from the code)
If it is being used for its side effect (as in your" print "example), then a loop is clear.
If the composite value To make the recurrence is executed, the calculation of the list is usually more readable.
Comments
Post a Comment