Python indentation error after try: -


i have problem, whenever try run python script on raspberry pi:

import socket import sys  # create tcp/ip socket sock = socket.socket(socket.af_inet, socket.sock_stream)  # bind socket port server_address = ('localhost', 10000) print >>sys.stderr, 'starting on %s port %s' % server_address sock.bind(server_address)  # listen incoming connections sock.listen(1)  while true:     # wait connection     print >>sys.stderr, 'waiting connection'     connection, client_address = sock.accept()      try:         print >>sys.stderr, 'connection from', client_address          # receive data in small chunks , retransmit         while true:             data = connection.recv(16)             print >>sys.stderr, 'received "%s"' % data             if data:                 print >>sys.stderr, 'sending data client'                 connection.sendall(data)             else:                 print >>sys.stderr, 'no more data from', client_address                 break      finally:         # clean connection         connection.close() 

i error:

 file "server.py", line 20     try:     ^ indentationerror: unexpected indent 

could please tell me what's wrong here? script supposed create simple tcp/ip server, , have no such problems client, don't understand mistake/s...

one of unfortunate side-effects of python's use of whitespace denoting blocks scripts have tabs , spaces mixed throughout source code.

since script pretty small, try deleting whitespace preceding each line's code , reindent properly.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -