Feb-23-2021, 11:35 PM
Hello Dear
Before few days ago I was code password generator and I had problem that the output text file only write last line my code was like this
but today when I code md5 encryption every work ok until I want to write it to file its back to old problem only save last line
this is my code that I need to solve there are no error in command line print every thing but again only export last line
full code
Windows 10
Best regards
Before few days ago I was code password generator and I had problem that the output text file only write last line my code was like this
pwd = open("passwords.txt", "w") pwd.write(password +"\n" ) pwd.close()and I changed w to a (appended) and its work and print all output lines
but today when I code md5 encryption every work ok until I want to write it to file its back to old problem only save last line
this is my code that I need to solve there are no error in command line print every thing but again only export last line
full code
import hashlib with open('strings.txt') as f: for line in f: line = line.strip() print(f'{hashlib.md5(line.encode()).hexdigest()} ') pwd = open("passwords.txt", "a") pwd.write(str(f'{hashlib.md5(line.encode()).hexdigest()} ')) pwd.close()Python 3.9
Windows 10
Best regards