Python 3.x 如何修复:提交Python代码时,预期输出为2,但在意大利面上得到0
我正在使用Python3为搜索算法编写一些代码。代码在pc上返回预期的字符串(使用命令提示符+Edstem),但在意大利面上测试后,“输出行数不正确。预期为2,但得到0。”错误弹出 有什么问题吗?为什么代码只在pc上返回字符串,而在意大利面上不返回 我试图检查是否有多余的空格、逗号和空行,但没有一个是导致错误的问题 def main(): 如果名称=='main': main() solve()方法返回2个字符串,每行1个。在命令提示符下测试并工作,但未收到任何输出Python 3.x 如何修复:提交Python代码时,预期输出为2,但在意大利面上得到0,python-3.x,Python 3.x,我正在使用Python3为搜索算法编写一些代码。代码在pc上返回预期的字符串(使用命令提示符+Edstem),但在意大利面上测试后,“输出行数不正确。预期为2,但得到0。”错误弹出 有什么问题吗?为什么代码只在pc上返回字符串,而在意大利面上不返回 我试图检查是否有多余的空格、逗号和空行,但没有一个是导致错误的问题 def main(): 如果名称=='main': main() solve()方法返回2个字符串,每行1个。在命令提示符下测试并工作,但未收到任何输出 # Parse in the
# Parse in the command line arguments
parser = argparse.ArgumentParser()
parser.add_argument('search_algorithm')
parser.add_argument('input_file')
args = parser.parse_args()
# Parse in the input file
with open(args.input_file, 'r') as input_file:
content = input_file.readlines()
for i in range(0,len(input_file.readlines())):
content[i].strip('\n')
start_node = int(content[0])
end_node = int(content[1])
if len(content) == 3:
# there are forbidden states, insert them in a list
forbidden_states = list(content[2].split(','))
if forbidden_states == '\n':
forbidden_states = []
else:
for num in range(0,len(forbidden_states)):
forbidden_states[num] = int(forbidden_states[num])
else:
forbidden_states = []
# Create a ThreeDigits object
threeDigitsSolver = ThreeDigits(args.search_algorithm, start_node, end_node, forbidden_states)
# Call solve to get a string with the search path and visited states, then print
print(threeDigitsSolver.solve())