Python Forum
open, read and replace a string in a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
open, read and replace a string in a file
#1
Hi,
i want to read a file, and replace a certain value.

i don t know the exact string value but i know what is before and after this value

for optimization reason i want to open the file only one time.

any help please?

example of file :

{"azure": {"ENDPOINT":"another sms", "DB_NAME": "db",}
so the value i want to replace here is another sms, and i know that before it, i have "ENDPOINT":" and after it i have ",

how can i do it please
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Beautiful Soup] Replace tag.string from another file? Winfried 1 153 10 hours ago
Last Post: Winfried
  Replace values in Yaml file with value in dictionary PelleH 1 2,203 Feb-11-2025, 09:51 AM
Last Post: alexjordan
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 1,188 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Trying to open depracated joblib file mckennamason 0 757 Sep-19-2024, 03:30 PM
Last Post: mckennamason
  Read TXT file in Pandas and save to Parquet zinho 2 1,303 Sep-15-2024, 06:14 PM
Last Post: zinho
Question [SOLVED] How to replace characters in a string? Winfried 2 1,070 Sep-04-2024, 01:41 PM
Last Post: Winfried
  Pycharm can't read file Genericgamemaker 5 1,631 Jul-24-2024, 08:10 PM
Last Post: deanhystad
  Python is unable to read file Genericgamemaker 13 3,941 Jul-19-2024, 06:42 PM
Last Post: snippsat
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 3,374 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Open/save file on Android frohr 0 1,153 Jan-24-2024, 06:28 PM
Last Post: frohr

Forum Jump:

User Panel Messages

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