我发现查询以下内容占用了大部分的加载时间,有什么方法可以多处理这个吗?列表和变量已经在前面定义过,并且包含数据
for i in range(len(allTrainDataList)):
allTrainsRouteJSON = requests.get('https://api.com/'+mergeAllTrainDataList[i]+'/'+date,
auth=('username', 'password'))
allTrainServiceJson = allTrainsRouteJSON.json()
listOfAllStations=[]
try: noSchedule = str(allTrainServiceJson['error'])
except: noSchedule="FALSE"
if noSchedule=="FALSE":
#Sanity check - Was main station on the planned route?
for j in allTrainServiceJson['locations']:
#Potentially put the if statements here to run each of the route defs
listOfAllStations.append(str(j['crs'])+mergeAllTrainDataList[i])
toBeChecked=[fromStation+allTrainDataList[i],toStation+mergeAllTrainDataList[i]]
toBeChecked2=[returnFromStation+allTrainDataList[i],returnToStation+mergeAllTrainDataList[i]]
if contains_in_order(listOfAllStations,toBeChecked):
allTrainDataListFinal.append(mergeAllTrainDataList[i])
if contains_in_order(listOfAllStations,toBeChecked2):
allTrainDataListFinal2.append(mergeAllTrainDataList[i])
目前没有回答
相关问题 更多 >
编程相关推荐