File tree 3 files changed +52
-2
lines changed
3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 202
202
" f.readlines()"
203
203
]
204
204
},
205
+ {
206
+ "cell_type" : " code" ,
207
+ "execution_count" : 19 ,
208
+ "metadata" : {},
209
+ "outputs" : [],
210
+ "source" : [
211
+ " file = open('geek.txt','w') \n " ,
212
+ " file.write(\" This is the write command\" ) \n " ,
213
+ " file.write(\" It allows us to write in a particular file\" ) \n " ,
214
+ " file.close() "
215
+ ]
216
+ },
217
+ {
218
+ "cell_type" : " code" ,
219
+ "execution_count" : 20 ,
220
+ "metadata" : {},
221
+ "outputs" : [],
222
+ "source" : [
223
+ " file = open('geek.txt','a') \n " ,
224
+ " file.write(\" This will add this line\" ) \n " ,
225
+ " file.close() "
226
+ ]
227
+ },
228
+ {
229
+ "cell_type" : " code" ,
230
+ "execution_count" : 24 ,
231
+ "metadata" : {},
232
+ "outputs" : [],
233
+ "source" : [
234
+ " with open(\" test.txt\" ) as file:\n " ,
235
+ " data = file.read() "
236
+ ]
237
+ },
238
+ {
239
+ "cell_type" : " code" ,
240
+ "execution_count" : 25 ,
241
+ "metadata" : {},
242
+ "outputs" : [],
243
+ "source" : [
244
+ " with open(\" file.txt\" , \" w\" ) as f:\n " ,
245
+ " f.write(\" Hello World!!!\" ) "
246
+ ]
247
+ },
205
248
{
206
249
"cell_type" : " code" ,
207
250
"execution_count" : null ,
208
251
"metadata" : {},
209
252
"outputs" : [],
210
- "source" : []
253
+ "source" : [
254
+ " with open(\" file.text\" , \" r\" ) as file: \n " ,
255
+ " data = file.readlines() \n " ,
256
+ " for line in data: \n " ,
257
+ " word = line.split() \n " ,
258
+ " print word "
259
+ ]
211
260
}
212
261
],
213
262
"metadata" : {
Original file line number Diff line number Diff line change
1
+ Hello World!!!
Original file line number Diff line number Diff line change 1
- This is the write commandIt allows us to write in a particular file
1
+ This is the write commandIt allows us to write in a particular fileThis will add this line
You can’t perform that action at this time.
0 commit comments