Skip to main content
 首页 » 编程设计

Python循环PEP8规则

2025年05月04日14jillzhang

<分区>

Possible Duplicate:
Is it possible to implement a Python for range loop without an iterator variable?

只是想多次做某事所以我写

    for i in range(1, 10): 
        print 'something' 
        print 'do not use i' 

所以当我运行 PyLint 时它说:当然是“未使用的变量‘i’”。 那么在我只想循环多次的地方编写这种类型的循环的正确方法是什么。

    i = 0 
    while i < 10: 
        print 'test' 
        i += 1 

只有这样吗?