Python 导入文件过程图解

Hursan 20 0 PDF 2021-01-31 15:01:56

1、同级目录下调用 若在程序 testone.py 中导入模块 testtwo.py , 则直接使用 【import testtwo 或 from testtwo import *】 2、调用子目录下的模块 若在程序 testone.py 中导入模块 test1_1.py , 则test1文件夹下必须要有 __init__.py 文件,此时的 test1 就是一个包 导入如下: 【import test1.test1_1 或 from test1.test1_1 import *】 3、调用上级目录下的文件 若在程序 test2_1.py 中导入模块 test1_1.py 和 testo

用户评论
请输入评论内容
评分:
暂无评论