AttributeError: 'int' 对象没有 'state' 属性
当我运行目前的代码时,这个错误就出现了。
注意:这段代码不是我写的,我只是想搞明白发生了什么,好把它移植到TuLiP的新版上。
Traceback (most recent call last):
File "vms5.py", line 270, in <module>
states = [aut_state.state]
AttributeError: 'int' object has no attribute 'state'
第270行写着:
states = [aut_state.state]
我试着找了找state
,在第249行找到了这个:
state = dict(temp = Tmax, w = 0, h = 0, b = Bmax, a = 0, c = 0, nw = 0)
还有在第259和260行找到了aut_state
aut = createAut(aut_file = autfile, varnames = env_vars.keys() + sys_disc_vars.keys())
aut_state = aut.findNextAutState(current_aut_state=None, env_state=state)
其他带aut
的词
第47行:
autfile = testfile+'.aut'
以及第223到234行
# Check realizability
realizability = jtlvint.checkRealizability(smv_file=smvfile, spc_file=spcfile, \
aut_file=autfile, verbose=3)
# Compute an automaton
jtlvint.computeStrategy(smv_file=smvfile, spc_file=spcfile, aut_file=autfile, \
priority_kind=3, verbose=3)
aut = automaton.Automaton(autfile, [], 3)
这就是代码中所有与aut
相关的内容
如果你需要更多信息,请告诉我
编辑
我在第270行之前加了print(aut_state)
,结果得到了-1
。
2 个回答
0
从错误信息来看,aut_state
是一个整数,而整数是没有叫 state
的属性的。你主要的问题出在 createAut()
这个函数里,它是用来创建一个自动机对象的,或者是在 findNextAutState()
这个函数里,它返回了 aut_state
。
0
所以aut是一个整数。整数是没有叫做state的属性的。无论是什么给aut这个变量赋值,都是用一个整数。看起来像是一个错误代码。看看findNextAutState这个函数的代码——当没有更多的AutStates时,它返回什么?是-1吗?
可能是缺少了一个条件检查。