Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python read and delete line from file

with open("yourfile.txt", "r") as f:
    lines = f.readlines()
with open("yourfile.txt", "w") as f:
    for line in lines:
        if line.strip("
") != "nickname_to_delete":
            f.write(line)
Comment

PREVIOUS NEXT
Code Example
Python :: pandas iterate columns 
Python :: pandas apply with multiple arguments 
Python :: accessing dictionary elements in python 
Python :: tkinter window background color 
Python :: how to check if all characters in string are same python 
Python :: discord.py get profile picture 
Python :: make new app folder in django templates dir 
Python :: change freq of date index in pandas 
Python :: make calculator in python 
Python :: python fernet 
Python :: flask db migrate 
Python :: root number in python 
Python :: pop vs remove python 
Python :: The operands of the logical operators should be boolean expressions, but Python is not very strict. Any nonzero number is interpreted as True. 
Python :: python string to datetime 
Python :: turtle write 
Python :: smtp email template 
Python :: django model current timestamp 
Python :: http.server python 
Python :: pandas to_csv no index 
Python :: how to create a new virtualenv 
Python :: merge two dataframes with common columns 
Python :: print value of tensor 
Python :: last history of whatsapp message with python 
Python :: python check if string is number reges 
Python :: python process memory usage 
Python :: python beautifulsoup get content of tag 
Python :: pandas new column from others 
Python :: merge two df 
Python :: pyodbc sql save pandas dataframe 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =