jackfrued / jackfrued/Python-100-Days

Day7 「生成式和生成器」 代码报错,可以优化一下以便初学者

Open Beginner friendly
#450 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
187k
Forks
55.8k
PR merge metrics
No merged PRs in 30d

Description

「07.字符串和常用数据结构.md」中「生成式和生成器」 的示例代码用到了 sys 模块的函数,所以程序执行到 print(sys.getsizeof(f)) 这一步时会报如下错误:

Exception has occurred: NameError
name 'sys' is not defined

需要在开头加上 import sys 或者 from sys import getsizeof

今天7号刚好学到第7天的教程,希望能早点学完~

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

Open 「07.字符串和常用数据结构.md」 and locate the 「生成式和生成器」 examples. Run the example through print(sys.getsizeof(f)) and add the missing sys import at the beginning; done means the example runs without the reported NameError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.