當我嘗試寫到另一個文件,我得到一個錯誤說:我如何寫一個int到文件
TypeError: write() argument must be str, not int
我如何寫一個int到一個文件?下面是我當前的代碼
infile = open("milk.in","r").readlines()
outfile = open("milk.out","w")
a, b = infile[0].split()
a, b = int(a), int(b)
sum = a + b
outfile.write(sum)
outfile.close()