在我下面的脚本中
def main():
file= open("NCSIDS_ObsExp.txt", "r")
for line in file:
line= line.split(',')
print line
file.close()
main()
我得到:
['Ashe', '1853282.679', '1673876.66', '1 ', '2 \n']
['Alleghany', '1963178.059', '1695301.229', '0 ', '1 \n']
我该如何摆脱\n
?我对 strip() 函数很困惑。我收到一个错误。
def main():
file= open("NCSIDS_ObsExp.txt", "r")
for line in file:
line= line.split(',')
append= line.strip('n')
print line
file.close()
main()