我的程序有问题,是否有人可以帮我修复它?程序运行时出错(Python)
目的:
在input.txt中:
7 12
100
Output.txt的:
84 16
84是从7 * 12和16是从100-84
这是我现在的代码:
with open('sitin.txt', 'r') as inpt:
numberone = inpt.readlines()[0].split(' ') # Reads and splits numbers in the first line of the txt
numbertwo = inpt.readlines()[1] # Reads the second line of the txt file
product = int(numberone[0])*int(numberone[1]) # Calculates the product
remainder = int(numbertwo)-product # Calculates the remainder using variable seats
with open('sitout.txt', 'w') as out:
out.write(str(product) + ' ' + str(remainder)) # Writes the results into the txt
它不输出任何内容。 有人可以帮忙吗? 在此先感谢任何人的帮助!
你得到一个错误信息? – BenT
@BenT我怎么看?当我打开它时,该框消失得太快,无法阅读错误消息。 –