关于我下面的代码(Python语言),为什么下面的打印语句(在get_a_maximal_subset函数中)
file = open("_probe","a")
file.write("\n new_ref_array: \n")
file.write(str(new_ref_array))
file.close
在(在下面的参考代码中)之前打印到文件中
file = open("_probe","a")
file.write("\n local_array \n")
file.write(str(local_array))
file.close
我在 _probe 文件中得到以下输出:
测试点 2
测试点 3
测试点 3-b
测试点 3-c
新参考数组:
[10, 1]
新参考数组:
[10, 1]
本地数组
[10, 1]
测试点 4
ISSUE:似乎应该在“new_ref_array”行之前而不是在“new_ref_array”行之后打印“local array”,因为“new_ref_array”行来自 get_a_maximal_array 函数并且代码顺序是:
local_array = list(array[i:])
file = open("_probe","a")
file.write("\n local_array \n")
file.write(str(local_array))
file.close
i = i + 1
subset_candidate = get_a_maximal_subset(local_array, max, prefix)
====================下面是我的代码============================ =================
while (determination_process == True):
file = open("_probe","a")
file.write("\n test point 2 \n")
file.close
i = 0
for x in array:
file = open("_probe","a")
file.write("\n test point 3 \n")
file.close
prefix = []
local_process_ref = [max+1]
if (determination_process != True):
break
if (x not in global_process_ref):
file = open("_probe","a")
file.write("\n test point 3-b \n")
file.close
global_process_ref.append(x)
file = open("_probe","a")
file.write("\n test point 3-c \n")
file.close
local_array = list(array[i:])
file = open("_probe","a")
file.write("\n local_array \n")
file.write(str(local_array))
file.close
i = i + 1
subset_candidate = get_a_maximal_subset(local_array, max, prefix)
file = open("_probe","a")
file.write("\n test point 4 \n")
file.close