selfteaching / selfteaching/selfteaching-python-camp

【自学内容】 对于打开文件with open('file','r') as f: .....f.read()的类比理解

Open
#1,751 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

有些东西,我们如果不能用已知的东西去理解的话,即使非常简单也同样错误百出。with open(‘’) as f: 之后一定要用read()函数,读取容器里面的文件。其实这也很好理解,装进文本里面的字符串,就相当于,一 瓶瓶的矿泉水装进了一个箱子里面封装了起来,这个时候,你第一步要做的就是打开这个箱子。好,你看到了水 ,但是这个时候,你还没真正的接触到水,还需要你用手打开瓶盖,直到用嘴巴喝到水才实现了你的喝水目的。 同样的,我们要打开文本,读取文字就相当于这么一个操作。首先把文本这个东西找到,找到之后再通过一定的 手段读取字符串文本,这个手段就是read()这个方法,然后用列表容器装起来。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue contains only a Chinese explanation of Python's with open('file','r') as f and f.read() example; no target file or test is named. First locate where self-learning content is stored and check the contribution guidance. Done means the intended documentation location and required wording or correction are agreed and the explanation is included there.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.