打卡day30

知识点回顾:

  1. 导入官方库的三种手段
  2. 导入自定义库/模块的方式
  3. 导入库/模块的核心逻辑:找到根目录(python解释器的目录和终端的目录不一致)

作业:自己新建几个不同路径文件尝试下如何导入

复制代码
from lib.utils import add  
from lib.sublib.helper import helper_func  
print(add(2, 3))  
print(helper_func(3))  
def add(a, b):  
    return a + b  
from ..utils import add  
def helper_func(x):  
    return add(x, x)  
import sys  
sys.path.append('../')  
from lib.utils import add  
def test_add():  
    assert add(1, 2) == 3, "测试失败"  
test_add()  
print("测试通过!")  

@浙大疏锦行

相关推荐
松仔log8 分钟前
Kotlin中级——KMP
android·开发语言·kotlin
龙腾AI白云15 分钟前
多源数据融合:把零散信号拼成一致图景
大数据·人工智能·python·机器学习·知识图谱
H H.26 分钟前
Java笔记:String字符串
java·开发语言·经验分享·笔记·其他
艾派森38 分钟前
深度学习实战-基于VGG19的健康和白化珊瑚图像分类识别模型
人工智能·python·深度学习·分类
鲸渔44 分钟前
【AI Agent系列课程26-Python 基础26】复盘:Python 接口开发知识清单
开发语言·python·ai编程
sharemylove1 小时前
Java 异常处理 学习笔记
java·开发语言·经验分享·笔记·学习
西西弗Sisyphus1 小时前
Qt QML 程序是怎么跑起来的(1)qml-only
开发语言·c++·qt
2401_868534781 小时前
55 个热门网络面试问题及答案
网络·python
aifannihao1 小时前
ON CONFLICT 冲突后返回空:sqlite3 实测 get-or-create
数据库·python·postgresql·sqlite3·标准库
用户0332126663672 小时前
使用 Python 合并 Excel 工作簿
python