我剛剛啓動python,所以我很可能只是在做一些愚蠢的事情。我正在讀取表中的數據,並且需要將它們放入txt文件的列中。我無法說服我的代碼創建一個新行。Python語法錯誤:行後續字符意外字符
這裏是我的代碼 -
file = open("test_m.rdb")
table = open('table.txt', 'w+')
trash = file.readline()
trash = file.readline()
data = file.readline()
i = data.split()
flux = i[2]
observed = i[4]
table.write(flux + " " + observed,)
while 1:
line = file.readline()
i = line.split()
try:
flux = i[2]
observed = i[4]
except IndexError:
break
table.write(\nflux + " " + observed)
table.close()
和錯誤載錄如下─
File "PlotRdbFile.py", line 24
table.write(\nflux + " " + observed)
^
SyntaxError: unexpected character after line continuation character
預先感謝您尋找我的錯誤。
可能的重複的[語法錯誤:「意外的字符後續行字符在Python中」數學](http://stackoverflow.com/questions/7791913/syntaxerror-unexpected-character-after-line-continuation-character-in- python) – smathy