for循环,pydev提示未使用的变量,解决办法

对于如下代码,pvdev会产生未使用变量的警告

1 for i in range(5):
2     func()

解决办法:

把变量替换成下划线_,就不会生产告警了。改变后如下:

1 for _ in range(5):
2     func()

原因:

>>> 1+2
3
>>> _
3

http://stackoverflow.com/questions/818828/is-it-possible-to-implement-a-python-for-range-loop-without-an-iterator-variable

原文地址:https://www.cnblogs.com/testlife007/p/4514491.html