Python Forum
dictionary output to text file (beginner)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dictionary output to text file (beginner)
#3
You can tell print() to print to a file.:
with open('datafile1.txt', 'a') as f:
    print("\nThis prints the key and its associated values")  # Prints to terminal
    for person in data['returnData']:
        print(f"Elid: {person['elid']}, Last Name: {person['name']}", file=f)  # Prints to file
Reply


Messages In This Thread
RE: dictionary output to text file (beginner) - by deanhystad - Jul-12-2023, 11:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  to find in dictionary given parameter 'name' and to output position Liki 10 1,398 Oct-08-2023, 06:38 AM
Last Post: Pedroski55
  Output File ? Kessie1971 11 2,064 May-11-2023, 08:31 AM
Last Post: buran
  beginner having text based adventure trouble mrgee 2 2,087 Dec-16-2021, 05:07 AM
Last Post: buran
  Using dictionary to find the most sent emails from a file siliusu 6 7,619 Apr-22-2021, 06:07 PM
Last Post: siliusu
  Updating dictionary in another py file tommy_voet 1 4,924 Mar-28-2021, 07:25 PM
Last Post: buran
  Making a dictionary from a file instyabam 0 1,520 Oct-27-2020, 11:59 AM
Last Post: instyabam
  how can i create a dictionary of dictionaries from a file Astone 2 2,281 Oct-26-2020, 02:40 PM
Last Post: DeaD_EyE
  Convert all actions through functions, fill the dictionary from a file Astone 3 2,455 Oct-26-2020, 09:11 AM
Last Post: DeaD_EyE
  Read text file, process data and print specific output Happythankyoumoreplease 3 2,936 Feb-20-2020, 12:19 PM
Last Post: jefsummers
  Parse text from a .txt file and save multiple output .txt rattlerskin 10 11,107 Aug-25-2019, 08:50 PM
Last Post: dwirsig

Forum Jump:

User Panel Messages

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