프로젝트를 진행 중입니다.이 웹 사이트의 예제를 따르는 TCP/IP 서버의 기본 사항을 얻고 싶습니다. https://pymotw.com/2/socket/tcp.html 다음 코드는 다음 코드와 동일합니다. 알아. 나는이 코드를 컴파일 할 때TCP/IP 서버가 마침내 : 구문이 잘못되었습니다.
while True:
print >>sys.stderr, 'waiting for a connection'
connection, client_address = sock.accept()
try:
print >>sys.stderr, 'client connected:', client_address
while True:
data = connection.recv(16)
print >>sys.stderr, 'received "%s"' % data
if data:
connection.sendall(data)
else:
break
finally:
connection.close()
그러나, 내가 오류는 다음과 같습니다 그래서 내가 여기에 무슨 일이 일어나고 있는지 확실하지 오전, 어떤 도움이 될 것 내가 파이썬과 많은 경험이없는
File "server.py", line 26
finally:
^
SyntaxError: invalid syntax
높이 평가
파이썬에서 들여 쓰기가 중요합니다. –
감사합니다. 나 didnt는 이것을 안다 :) – Geedubs123
당신을 환영한다. [시작하기] (https://wiki.python.org/moin/BeginnersGuide/Programmers)를 원할 수도 있습니다. :) –