Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
24 lines (20 loc) · 384 Bytes

File metadata and controls

24 lines (20 loc) · 384 Bytes
Copy raw file
Download raw file
Edit and raw actions
@author jackzhenguo
@desc
@tag
@version 
@date 2020/03/02

充分认识for

In [65]: for i in range(5):
    ...:   print(i)
    ...:   i = 10
0
1
2
3
4

为什么不是执行一次就退出?

按照for在Python中的工作方式, i = 10 并不会影响循环。range(5)生成的下一个元素就被解包,并赋值给目标列表的变量i.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.