Skip to content

Commit e6049e0

Browse files
committed
File
1 parent c6c7c2a commit e6049e0

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

Diff for: 05.InOut.ipynb

+50-1
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,61 @@
202202
"f.readlines()"
203203
]
204204
},
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+
},
205248
{
206249
"cell_type": "code",
207250
"execution_count": null,
208251
"metadata": {},
209252
"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+
]
211260
}
212261
],
213262
"metadata": {

Diff for: file.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World!!!

Diff for: geek.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
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

0 commit comments

Comments
 (0)