-2
我試圖推動一個項目在Python的堆棧。下面是試圖推動該項目的代碼:在python中使用堆棧給出了NoneType錯誤
class Search
def generalGraphSearch(problem,fringe):
closed=set()
#If no nodes
if problem.isGoalState(problem.getStartState()):
return problem.getStartState()
#Create object of Stack class
stackOb = util.Stack()
"""Push the starting node into the stack. The parameter is the state"""
stackOb.push(problem.getStartState())
print stackOb.push(problem.getStartState())
The stack implementation is as below :
class Stack:
"A container with a last-in-first-out (LIFO) queuing policy."
def __init__(self):
self.list = []
def push(self,item):
"Push 'item' onto the stack"
self.list.append(item)
在搜索類print語句給出類型爲無
任何建議如何解決這個問題? 感謝
謝謝您的回覆。它幫助 – user6622569
@ user6622569好的,當然,看看你能否接受答案,謝謝。 – alecxe