You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: File.py
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,4 +25,16 @@
25
25
# for third line you have to write this function again
26
26
printLine=line.readline() #this print only first line of file
27
27
print(printLine)
28
-
line.close()
28
+
line.close()
29
+
30
+
31
+
32
+
## Now How to write or create a new file using ".write()" function
33
+
letFile=open("mydata.txt",'w') #we have not any file with "mydata.txt" than it will create this file
34
+
Details=letFile.write("Make this file with name mydata")
35
+
letFile.close()
36
+
37
+
# Now add other text in file "mydata.txt" with appending "a" i=use in ".open()" function
38
+
Addtext=open('mydata.txt','a')
39
+
done=Addtext.write('file is create with this we can add as much as data we want to write in this file using ".open(file_name,"a") than you can append data.')
40
+
Addtext.close()#after this our file is updated you can check in that file.
Make this file with name mydatafile is create with this we can add as much as data we want to write in this file using ".open(file_name,"a") than you can append data.
0 commit comments