Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 混淆功能_Python_Function_Pycharm - Fatal编程技术网

Python 混淆功能

Python 混淆功能,python,function,pycharm,Python,Function,Pycharm,我刚开始做一个函数,这是我现在的代码: def shortest_path(source, target): frontier_d = {} frontier_d[source]=1 raise NotImplementedError 基本上,我正在尝试制作一个字典,并将函数的输入source作为与值1关联的键。然而,Pycharm告诉我来源是一个未解决的引用。如果源是函数的输入,为什么会发生这种情况?请查看此项- 输出:{'abc':156}错误的屏幕截图或

我刚开始做一个函数,这是我现在的代码:

def shortest_path(source, target):

    frontier_d = {}

    frontier_d[source]=1


    raise NotImplementedError
基本上,我正在尝试制作一个字典,并将函数的输入source作为与值1关联的键。然而,Pycharm告诉我来源是一个未解决的引用。如果源是函数的输入,为什么会发生这种情况?

请查看此项-


输出:{'abc':156}

错误的屏幕截图或完整输出会更好。请将其减少并增强为预期值。您尚未显示调用函数的位置,问题可能就在那里。你能在调用
最短路径
时添加一行额外的代码,并包含运行它时得到的任何回溯吗?此外,提高利率也会使这项测试的内容变得混乱。最好把它拿出来。
source="abc"
target=156
def shortest_path(source, target):
    try:
        frontier_d = {}
        frontier_d[source]=target
        print(frontier_d)
    except:
        raise NotImplementedError
shortest_path(source, target)