python两个函数中传递变量_如何将一个变量的两个参数传递到函数中?

我得到了一个实现优先级队列的类,它使用一个函数来计算优先级。在class PriorityQueueWithFunction(PriorityQueue):

"""

Implements a priority queue with the same push/pop signature of the

Queue and the Stack classes. This is designed for drop-in replacement for

those two classes. The caller has to provide a priority function, which

extracts each item's priority.

"""

def __init__(self, priorityFunction):

# type: (object) -> object

"priorityFunction (item) -> priority"

self.priorityFunction = priorityFunction # store the priority function

PriorityQueue.__init__(self) # super-class initializer

def push(self, item):

"Adds an item to the queue with priority from the priority function"

PriorityQueue.push(self, item, self.priorityFunction(item))

我还得到了一个priority函数,我将用它初始化上面的类。在

^{pr2}$

以上代码是给我们的,我们不能更改它。我必须创建PriorityQueueWithFunction类并将元素推送到它。类的push函数接受参数item。但我的优先权函数是2。

我应该使用什么样的参数来将正确的elemnt推送到类中,并且使priorityfunction正常工作?在

这就是我所尝试的,我得到了编译错误,manhattanHeuristic…接受2个参数,1个给定#Creating a queingFn

queuingFn = PriorityQueueWithFunction(heuristic)

Frontier = queuingFn

#Creating the item that needs to be pushed

StartState = problem.getStartState()

StartNode = (StartState,'',0,(-1,-1))

#Here is my problem

item = StartState , problem

Frontier.push(item)

我要改变我的物品的形式吗?有什么想法吗?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值