Skip to content

Commit 41311bb

Browse files
committed
By tymcmf selfteaching#778
1 parent 497e5a6 commit 41311bb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Part.1.E.7.files.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
{
5555
"data": {
5656
"text/plain": [
57-
"<_io.TextIOWrapper name='test-file.txt' mode='w' encoding='UTF-8'>"
57+
"<_io.TextIOWrapper name='/tmp/test-file.txt' mode='w' encoding='UTF-8'>"
5858
]
5959
},
6060
"execution_count": 1,

markdown/Part.1.E.7.files.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
open('/tmp/test-file.txt', 'w')
3030
```
3131

32-
<_io.TextIOWrapper name='test-file.txt' mode='w' encoding='UTF-8'>
32+
<_io.TextIOWrapper name='/tmp/test-file.txt' mode='w' encoding='UTF-8'>
3333

3434
当然,更多的时候,我们会把这个函数的返回值,一个所谓的 [file object](https://docs.python.org/3/glossary.html#term-file-object),保存到一个变量中,以便后面调用这个 file object 的各种 Methods,比如获取文件名 `file.name`,比如关闭文件 `file.close()`
3535

@@ -39,7 +39,7 @@ print(f.name)
3939
f.close()
4040
```
4141

42-
test-file.txt
42+
/tmp/test-file.txt
4343

4444
## 删除文件
4545

@@ -58,8 +58,8 @@ else:
5858
print(f'{f.name} does not exist.')
5959
```
6060

61-
test-file1.txt
62-
test-file1.txt deleted.
61+
/tmp/test-file1.txt
62+
/tmp/test-file1.txt deleted.
6363

6464
## 读写文件
6565

0 commit comments

Comments
 (0)