Python
Python
How You Can Do More Interesting Things With Python
(Part II)
Python for Statement
for in :
statement-block
my_dict = { ¡®k1¡¯: 1, ¡®k2¡¯: 2 }
for (k,v) in my_dict.items():
print( ¡°Key = %s, value = %s¡¯ % ( k, v ) )
¡ñ
¡ñ
¡ñ
For the sake of completeness, this is one way to iterate over a dict.
Iteration of a dict directly returns the keys.
It possible to get the values directly
Python for Statement
for in :
statement-block
Do not forget that:
¡ñ continue returns to the top of the loop and executes the .
¡ñ break ends the loop and starts execution after the statement-block.
Python while Statement
while :
statement-block
¡ñ
¡ñ
This is much simpler. Runs until the boolean is False.
I am going to skip examples here.
Python else on Iteration Statements
while :
statement-block
else:
statement-block
The else executes if the loop terminates without using break.
>>> while False:
...
break
... else:
...
print 'else'
...
else
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- python replace multiple character in string
- python yield function
- yahoo finance python module
- philosophers song monty python lyrics
- monty python drinking song lyrics
- monty python the philosophers song
- python venomous bite
- ball python venomous
- python list of dictionaries append
- python thousands separator python 3
- python including other python files
- python get python file path