This article was first published on the public account “Python Knowledge Circle”. Please go directly to the public account.
“It takes about 2.6 minutes to read the text
We all know that Python’s design philosophy is “elegant,” “unambiguous,” and “simple.” This is probably why many people choose Python. However, I have received feedback from some of my friends that their Python writing is not elegant or even bloated. Maybe your posture is wrong! Here are 10 elegant ways to use Python statements.
Assign values to multiple variables
Sometimes, you have multiple variables that need to be assigned. How do you assign them?
General method:
The conventional method is to assign values to variables individually.
a = 0
b = 1
c = 2Copy the code
Elegant method:
Directly corresponding to the order of one – to – one assignment.
a, b, c = 0, 1, 2Copy the code
Sequence unpacking
For more, please click here