python - EOL while scanning string literal -
this code , following error message: line 8 sepfile=readfile.read().split('\') syntaxerror: eol while scanning string literal me? thanks.
import matplotlib.pyplot plt import numpy np x=[] y=[] readfile = open (("/users/sun/desktop/text58.txt"), 'r') sepfile=readfile.read().split('\') readfile.close() plotpair in sepfile: xandy=plotpair.split(',') x.append(int(xandy[2])) y.append(int(xandy[1])) print x print y plt.plot(x,y) plt.title('tweet') plt.xlabel('') plt.ylabel('') plt.show()
\
special character in python string literals: starts escape sequence.
to fix problem, need double backslash:
sepfile=readfile.read().split('\\')
doing tells python using literal backslash rather escape sequence.
also, for
, keywords in python, needs lowercase:
for plotpair in sepfile:
Comments
Post a Comment