Jump to content
Tuts 4 You

HELP python syntaxError: invalid syntax


usman

Recommended Posts

Posted
Quote

 


import socket

def Main():
    host = "127.0.0.1"
    port = 5000

    s = socket.socket()
    s.bind((host, port))
    s.listen(1)
    c, addr = s.accept()
    print 'Connection From :' + str(addr)

    while True:
        data = c.recv(1024)
        if not data:
            break
        print "from connected user: "+str(data)
        data = str(data).upper()
        print "Sending" + str(data)
        c.send(data)
    c.close()

if __name__ == "__main__":
    Main()

 

 

the problem is i cannot run and getting this error

wtf.png

i dont get it at all, really need some help 

身勝手のごくい
Posted

Cannot see your image, code looks ok. Its python2 maybe u run it with 3?

If you run it on linux, dont use capitals on function names - ur case Main.

  • Like 1
Posted

thanks in advance

it works now 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...