4337 links
  • Arnaud's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
page 1 / 1
  • thumbnail
    python - How to search and replace text in a file? - Stack Overflow
    Sometime you cant use sed :(

    # Read in the file
    with open('file.txt', 'r') as file :
      filedata = file.read()

    # Replace the target string
    filedata = filedata.replace('ram', 'abcd')

    # Write the file out again
    with open('file.txt', 'w') as file:
      file.write(filedata)
    July 7, 2021 at 4:42:22 PM GMT+2 * - permalink - archive.org - https://stackoverflow.com/questions/17140886/how-to-search-and-replace-text-in-a-file
    python replace
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation