Nov-08-2020, 09:28 PM
(This post was last modified: Nov-08-2020, 09:28 PM by chubbychub.)
could someone help me write the proper code for reading the first line of a text file in c:\desktop\ptyhon\log.txt
here is the partial code that should be relevant to my question
here is the partial code that should be relevant to my question
def thread_loop(): secretcode = "oaixxxxxxxxxxxxjxjxjxjxj" HOST = '0.0.0.0' # Standard loopback interface address (localhost) PORT = 58900 # Port to listen on (non-privileged ports are > 1023) log_path = os.path.dirname(os.path.realpath(__file__)) + "\log.txt" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() while True: if stop_threads: break conn, addr = s.accept() with conn: conn.sendall(str.encode('test_right_here')) ######right here is where i want to read the first line from c:\desktop\log.txt while True: try: data = conn.recv(1024) if not data: break data_str = data.decode('utf-8') conn.close() #more script below..but too long to paste