我最近开始用Python编码,遇到一个问题,将函数返回的值赋给变量.
class Combolock:
def _init_(self,num1,num2,num3):
self.x = [num1,num2,num3]
def next(self, state):
print "Enter combination"
combo = raw_input(">")
if combo == self.x[state]:
print "Correct"
return 1
else:
print "Wrong"
return 0
def lock(self):
currentState = 0
while currentState < 2:
temp = next(currentState)
if temp == 1:
currentState = currentState + 1
else:
currentState = 99
print "ALARM"
Run Code Online (Sandbox Code Playgroud)
当我调用锁定函数时,我在行处出错
temp = next(currentState)
Run Code Online (Sandbox Code Playgroud)
说int对象不是迭代器.
| 归档时间: |
|
| 查看次数: |
164 次 |
| 最近记录: |