1. 程式人生 > >python學習-錯誤-多行打印合併成一行

python學習-錯誤-多行打印合併成一行

line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")

print "I'm going to write these to the file."

target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")

target.write好幾個重複,只用一個target.write打印出所有行

str = "%s\n%s\n%s\n" % (line1,line2,line3)
target.write(str)