Logo Questions Linux Laravel Mysql Ubuntu Git Menu

PYTHON-2.x Syntax error on line 1 but i don't see any?

the following file is located in this directory: /Users/whiteglider/Documents

name of file: server.py

this is my practice code which i just copied from http://www.tutorialspoint.com/python/python_networking.htm

    import socket


    while True:
        c, addr = s.accept()
        print 'Got connection from', addr
        c.send ('Thank you for connecting')

when i run it at Terminal, i type

$ python /Users/whiteglider/Documents/server.py

then i get:

File "/Users/whiteglider/Documents/server.py", line 1
SyntaxError: unexpected character after line continuation character

even if i change directory going to where the server.py file actually is and run

python server.py

i still get the same result.

(mac leopard 10.5.8)

like image 241
whiteglider Avatar asked Feb 24 '23 10:02


1 Answers

You've saved the file as a Rich Text Format file rather than a plain text file.

I don't know what editor you're using, but make sure to save the file as plain text / ASCII text, something like that, not RTF.

like image 147
agf Avatar answered Apr 25 '23 11:04