Horje
python how to replace a certain string in text Code Example
python how to replace a certain string in text
# 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)




Python

Related
user input of int type in python Code Example user input of int type in python Code Example
image from wikipedia module in python Code Example image from wikipedia module in python Code Example
python append list Code Example python append list Code Example
how append a directory based on current directory python Code Example how append a directory based on current directory python Code Example
how to split string with comma in python Code Example how to split string with comma in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7