import socket import json ADDRESS =('192.168.50.162',1881) client_type= 'test' def input_client_type(): return input("輸入:") client_type = input_client_type() client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(ADDRESS) ##print(client.recv(1024).decode(encoding='utf8')) ##send_data(client,'CONNECT') while True: a=input("輸入:") a=a+'\n' print('send:'+a) client.sendall(a.encode('utf8'))