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
  Replace values in Yaml file with value in dictionary PelleH 1 2,040 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 977 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Trying to open depracated joblib file mckennamason 0 685 Sep-19-2024, 03:30 PM
Last Post: mckennamason
  Read TXT file in Pandas and save to Parquet zinho 2 1,193 Sep-15-2024, 06:14 PM
Last Post: zinho
Question [SOLVED] How to replace characters in a string? Winfried 2 950 Sep-04-2024, 01:41 PM
Last Post: Winfried
  Pycharm can't read file Genericgamemaker 5 1,510 Jul-24-2024, 08:10 PM
Last Post: deanhystad
  Python is unable to read file Genericgamemaker 13 3,445 Jul-19-2024, 06:42 PM
Last Post: snippsat
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 3,137 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Open/save file on Android frohr 0 1,085 Jan-24-2024, 06:28 PM
Last Post: frohr
  file open "file not found error" shanoger 8 5,772 Dec-14-2023, 08:03 AM
Last Post: shanoger

Forum Jump:

User Panel Messages

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