Here's the code I wrote for a server, which requests user info and stores them into a file:
# Function : For each client def threaded_client(connection): ''' codes that request and receive user massage... ''' # write the info into credentials.txt: with open('credentials.txt', 'a') as f: print(credentials, file = f)
Ideally, when I exit the server and restart it, all the old and new info should be kept in the same dict.
Expected output:
{'username_1': 'his password', 'username_2': 'her password', 'a': 'b'}
Actual output:
{'username_1': 'his password'} {'username_2': 'her password', 'a': 'b'}
What could be the issue here?
https://stackoverflow.com/questions/66947706/how-to-append-to-a-file-in-the-same-dict-after-restarting-the-server-using-py April 05, 2021 at 10:46AM
没有评论:
发表评论