selfteaching / selfteaching/selfteaching-python-camp

Day07 在mymodule的同级目录下创建名为main.py的文件

Open
#530 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  • 这是第7天任务里的子任务1.5,我第一次以为main.py是和mymodule一样,同在自己的作业文件夹里,结果运行报错提示我无法导入stats_word,具体报错如下:

ModuleNotFoundError: No module named 'stats_word'

  • 我的第一个想法是自己的main.py建错位置了,尝试了把它拖拽到mymodule里。再次运行,打印出了结果。我就以为“在mymodule的同级目录下”是就“在mymodule里创建的意思”。

  • 其实不是这样的,“mymodule的同级目录”就是打开自己的作业文件夹就一眼能看到mymodule文件夹和main.py文件。错的不是文件的位置,而是我的导入方式。
    在教练 @realcaiying 和战友 @qiming09 的指导下,我知道了“因为stats_word上一级还有一个mymodule文件夹,所以导入函数时需要这样操作, from ... import... ”。
    自学并不是独自学习,有教练和战友很重要!

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

Read the Day07 task instructions and compare the described mymodule/main.py layout with the import discussion for stats_word. Clarify the sibling-directory placement and the import guidance, then run main.py to confirm that stats_word imports successfully.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.