我的程序有問題,是否有人可以幫我修復它?程序運行時出錯(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我怎麼看?當我打開它時,該框消失得太快,無法閱讀錯誤消息。 –