Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
exporting all lines
#1
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

    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
Reply


Messages In This Thread
exporting all lines - by YazeedbnMohmmed - Feb-23-2021, 11:35 PM
RE: exporting all lines - by BashBedlam - Feb-24-2021, 01:15 AM
RE: exporting all lines - by YazeedbnMohmmed - Feb-24-2021, 03:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Exporting Stock Fundamental Data to a CSV file with yahoo_fin DustinKlent 2 4,769 Aug-01-2022, 06:08 PM
Last Post: paulyan
  Exporting dataframes to excel without loosing datetime format Rafa 0 1,254 Oct-27-2021, 10:42 AM
Last Post: Rafa
  Exporting a huge dataFrame stylingpat 5 15,780 Mar-23-2021, 12:13 AM
Last Post: stylingpat
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 5,998 Aug-10-2020, 11:01 PM
Last Post: medatib531
  Python code for exporting table using Selenium gj31980 4 3,056 Aug-04-2020, 01:29 AM
Last Post: gj31980
  Exporting data from python into excel Zankawah 5 3,437 Jun-02-2020, 03:17 AM
Last Post: buran
  Exporting list with dictionary to Excel veromi22 0 3,069 Oct-15-2019, 12:54 AM
Last Post: veromi22
  Exporting to Excel Nirmal 5 2,813 Aug-08-2019, 12:22 PM
Last Post: Nirmal
  Exporting Python Output to Notepad Nirmal 4 3,639 Sep-02-2018, 02:36 PM
Last Post: Nirmal
  Exporting Json events to a text file uklipse 3 2,731 Aug-21-2018, 02:12 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020