Skip to content

Commit c6c7c2a

Browse files
committed
File
1 parent 02ffa17 commit c6c7c2a

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

Diff for: 05.InOut.ipynb

+71
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,77 @@
131131
"f.seek(0)"
132132
]
133133
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": 14,
137+
"metadata": {},
138+
"outputs": [
139+
{
140+
"name": "stdout",
141+
"output_type": "stream",
142+
"text": [
143+
"my first file\n",
144+
"This file\n",
145+
"\n",
146+
"contains three lines\n",
147+
"\n"
148+
]
149+
}
150+
],
151+
"source": [
152+
" print(f.read())"
153+
]
154+
},
155+
{
156+
"cell_type": "code",
157+
"execution_count": 15,
158+
"metadata": {},
159+
"outputs": [],
160+
"source": [
161+
"for line in f:\n",
162+
" print(line, end = '')"
163+
]
164+
},
165+
{
166+
"cell_type": "code",
167+
"execution_count": 16,
168+
"metadata": {},
169+
"outputs": [
170+
{
171+
"data": {
172+
"text/plain": [
173+
"''"
174+
]
175+
},
176+
"execution_count": 16,
177+
"metadata": {},
178+
"output_type": "execute_result"
179+
}
180+
],
181+
"source": [
182+
"f.readline()"
183+
]
184+
},
185+
{
186+
"cell_type": "code",
187+
"execution_count": 18,
188+
"metadata": {},
189+
"outputs": [
190+
{
191+
"data": {
192+
"text/plain": [
193+
"[]"
194+
]
195+
},
196+
"execution_count": 18,
197+
"metadata": {},
198+
"output_type": "execute_result"
199+
}
200+
],
201+
"source": [
202+
"f.readlines()"
203+
]
204+
},
134205
{
135206
"cell_type": "code",
136207
"execution_count": null,

Diff for: geek.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is the write commandIt allows us to write in a particular file

Diff for: test.txt

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ my first file
22
This file
33

44
contains three lines
5+
6+
Lastly, the readlines() method returns a list of remaining lines of the entire file. All these reading method return empty values when end of file (EOF) is reached.
7+
Lastly, the readlines() method returns a list of remaining lines of the entire file. All these reading method return empty values when end of file (EOF) is reached.
8+
Lastly, the readlines() method returns a list of remaining lines of the entire file. All these reading method return empty values when end of file (EOF) is reached.

0 commit comments

Comments
 (0)