Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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脚本(webpy)在尝试打开现有文件时发出http 500错误_Python_Json_File_Web.py - Fatal编程技术网

Python脚本(webpy)在尝试打开现有文件时发出http 500错误

Python脚本(webpy)在尝试打开现有文件时发出http 500错误,python,json,file,web.py,Python,Json,File,Web.py,所以我不是很确定这里的问题。。。基本上,只要我使用正在使用的实时API来获取数据,一切都可以正常工作。但是,如果我试图打开一个现有文件,其中包含与以前的api调用相同的精确数据,则会出现一个内部服务器错误。以下是导致问题的代码块: thisFile = os.path.join(__location__, '2014/' + npi + '_individual.json') # if the local cached copy exists, then load that,

所以我不是很确定这里的问题。。。基本上,只要我使用正在使用的实时API来获取数据,一切都可以正常工作。但是,如果我试图打开一个现有文件,其中包含与以前的api调用相同的精确数据,则会出现一个内部服务器错误。以下是导致问题的代码块:

    thisFile = os.path.join(__location__, '2014/' + npi + '_individual.json')

    # if the local cached copy exists, then load that, otherwise, connect to the API
    if os.path.isfile(thisFile):
        target2 = open(thisFile)
        content = json.loads(target2.read())
    else:
        req = urllib2.Request(url + '?database=nppes&npi=' + npi + '&apikey=' + apiKey)
        r = urllib2.urlopen(req)
        content = json.loads(r.read())

我相信我使用的是webpy或web2py,我不确定这是不是两个独立的东西。在Apache2.4上通过WSGI执行脚本。

这是一件无关的事情。基本上,这是失败的,因为。。。所以在第一次调用中,它细化了我从API返回的数据,然后将细化后的数据存储在json文件中

因此,在下一次加载时,json文件存在,当加载它时,一些东西在细化过程中被重命名,因此脚本的其余部分不知道如何执行。愚蠢的问题