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
  Open/save file on Android frohr 0 278 Jan-24-2024, 06:28 PM
Last Post: frohr
  file open "file not found error" shanoger 8 942 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Recommended way to read/create PDF file? Winfried 3 2,783 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,308 Nov-09-2023, 10:56 AM
Last Post: mg24
  Replace a text/word in docx file using Python Devan 4 2,846 Oct-17-2023, 06:03 PM
Last Post: Devan
  Need to replace a string with a file (HTML file) tester_V 1 699 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can i combine these two functions so i only open the file once? cubangt 4 805 Aug-14-2023, 05:04 PM
Last Post: snippsat
  read file txt on my pc to telegram bot api Tupa 0 1,047 Jul-06-2023, 01:52 AM
Last Post: Tupa
  parse/read from file seperated by dots giovanne 5 1,043 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
  Formatting a date time string read from a csv file DosAtPython 5 1,160 Jun-19-2023, 02:12 PM
Last Post: DosAtPython

Forum Jump:

User Panel Messages

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