About 24,100,000 results
Open links in new tab
  1. How to delete data from file in Python - GeeksforGeeks

    Apr 22, 2025 · Let’s explore the various ways to delete data from files. Consider our sample file sample.txt, which contains the following data: This method is used when you want to …

  2. How to delete a specific line in a text file using Python?

    Mar 16, 2023 · Do you want to remove a specific line from file so use this snippet short and simple code you can easily remove any line with sentence or prefix (Symbol). with …

  3. How to delete specific strings from a file? - Stack Overflow

    I have a data file (unstructured, messy file) from which I have to scrub specific list of strings (delete strings). Here is what I am doing but with no result: infile = r"messy_data_file.txt&q...

  4. How to erase the file contents of text file in Python?

    Feb 26, 2017 · do open('file.txt', 'w').close() as weird as it looks. #include<fstream> and then std::ofstream("file.txt"); about as short as in Python. :) the reason this works (in both C++ and …

  5. Python: How to Delete a text from a file and save it - PyTutorial

    May 14, 2023 · By using replace () method, you can delete a phrase or text from a file. Let's see how to use it.

  6. Python Program to Delete Specific Line from File

    Sep 5, 2024 · In this article, we are going to see how to delete the specific lines from a file using Python. Throughout this program, as an example, we will use a text file named months.txt on …

  7. File Handling in Python - Python Guides

    File handling is a crucial aspect of Python programming that allows you to work with files on your computer’s file system. Whether you need to read data from files, write results to files, or …

  8. Python Delete Lines From a File [4 Ways] – PYnative

    Jul 3, 2021 · Learn How to remove lines from a file by line numbers. Remove lines that match the specific text. Delete first and Last lines from file.

  9. Efficiently Deleting Text and Lines from Files in Python

    This article has explored some of the most common techniques for deleting lines and text from a file, including deleting lines by line numbers, matching given text or string, removing first and …

  10. How to Clear a Text File in Python - PythonForBeginners.com

    May 5, 2022 · In this post, we’ll use some simple examples to demonstrate how to clear a text file in Python. By making use of some of Python’s standard tools, we can open, read, and clear …

  11. Some results have been removed
Refresh