Python Forum
save values permanently in python (perhaps not in a text file)?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save values permanently in python (perhaps not in a text file)?
#6
Smile 
Dear community,

I got it working...

import json
pathA = "C://test//abc//"
pathB = "C://test//def//"

paths = {"pathA": pathA, "pathB": pathB}

# save
with open("paths.json", "w") as write_file:
    json.dump(paths, write_file)

#load
with open("paths.json", "r") as read_file:
    paths = json.load(read_file)

print(paths["pathA"])

print(paths["pathB"])
I can use it to let the user store some paths in the json file and does not have to define it again and again.
I will notice you when I need further advice...
Reply


Messages In This Thread
RE: save values permanently in python (perhaps not in a text file)? - by flash77 - Jul-06-2023, 08:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Open/save file on Android frohr 0 465 Jan-24-2024, 06:28 PM
Last Post: frohr
  how to save to multiple locations during save cubangt 1 681 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  Replace a text/word in docx file using Python Devan 4 4,676 Oct-17-2023, 06:03 PM
Last Post: Devan
  Save and Close Excel File avd88 0 3,558 Feb-20-2023, 07:19 PM
Last Post: avd88
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,290 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Save multiple Parts of Bytearray to File ? lastyle 1 1,057 Dec-10-2022, 08:09 AM
Last Post: Gribouillis
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,909 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Overwrite values in XML file with values from another XML file Paqqno 5 3,657 Apr-01-2022, 11:33 PM
Last Post: Larz60+
  How to split file by same values from column from imported CSV file? Paqqno 5 3,072 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  Converted Pipe Delimited text file to CSV file atomxkai 4 7,444 Feb-11-2022, 12:38 AM
Last Post: atomxkai

Forum Jump:

User Panel Messages

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