python中for循环的用法

文/

for循环是指一个通用的序列迭代器,用于遍历任何有序的序列对象内的元素,可用于字符串、元组、列表和其它内置可迭代对象,以及通过类所创建的新对象。

for循环语法格式

for expression in object:

for_suite

else:

else_suite

for语法格式扩展

for expression in object:

for_suite

if boolean_expression2: continue

if boolean_expression3: break

else:

else_suite

小编推荐

下载文档