Play with Text Files : using Python by Koduri Bhargav
Author:Koduri Bhargav [Bhargav, Koduri]
Language: eng
Format: azw3, epub
Published: 2021-06-22T00:00:00+00:00
A file old.txt can be renamed to new.txt, using the function os.rename(). The name of the file changes only if, the file exists and the user has sufficient privilege permission to change the file.
2.7 Modify a Record
2.6.1 Copy the line that you want to modify
f = open("pd.txt", "r")
nf=open("newfile.txt","a")
s=input("Enter name to modify: ")
for line in f:
if s not in line :
nf.write(line)
else:
phNum= input("Enter the phone numer: ")
res=" "+s+" "+phNum+"
"
nf.write(res)
f.close()
nf.close()
2.6.2 Delete the original textfile
import os
os.remove("pd.txt")
2.6.3 Rename the new text file with the original text file
Download
Play with Text Files : using Python by Koduri Bhargav.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Art of Coaching Workbook by Elena Aguilar(48044)
Trainspotting by Irvine Welsh(20046)
Twilight of the Idols With the Antichrist and Ecce Homo by Friedrich Nietzsche(17703)
Fangirl by Rainbow Rowell(7828)
Periodization Training for Sports by Tudor Bompa(7324)
Change Your Questions, Change Your Life by Marilee Adams(6637)
This Is How You Lose Her by Junot Diaz(5755)
Grit by Angela Duckworth(4729)
Red Sparrow by Jason Matthews(4655)
Asking the Right Questions: A Guide to Critical Thinking by M. Neil Browne & Stuart M. Keeley(4567)
Paper Towns by Green John(4165)
Room 212 by Kate Stewart(4099)
Ken Follett - World without end by Ken Follett(3968)
The Sports Rules Book by Human Kinetics(3582)
Housekeeping by Marilynne Robinson(3397)
The Motorcycle Diaries by Ernesto Che Guevara(3326)
Introduction to Kinesiology by Shirl J. Hoffman(3297)
Exercise Technique Manual for Resistance Training by National Strength & Conditioning Association(3288)
Double Down (Diary of a Wimpy Kid Book 11) by Jeff Kinney(3267)