创建python modu

2024-09-25 06:35:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了两个文件:测试.pytest1234.py

测试.py包含:

import test1234
t = test1234.test()

test1234.py包含:

^{pr2}$

当放入同一目录时,python test.py运行时不会出错。在

但是,如果我创建一个目录test1234,并将test1234.py和一个空白的init.py,则python test.py会给出错误:

AttributeError: 'module' object has no attribute 'test'

我需要为做什么测试.py能够在test1234.py中查看test类?在


Tags: 文件nopytestimport目录objectinit