What do you want to save?
Add Code snippet
New code examples
-
Python 2022-02-04 18:30:17
python replace string in file
# 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) Add solution -
Python 2022-02-01 12:56:25
website blocker python
#Import libraries import time from datetime import datetime as dt #Windows host file path hostsPath=r"C:\Windows\System32\drivers\etc\hosts" redirect="127.0.0.1" #Add the website you want to block, in this list websites=["www.yout... Add solution -
Python 2022-02-01 00:15:06
python find and replace string in file
# 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) Add solution
Best helpers
Ranking is empty