打卡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("测试通过!")  

@浙大疏锦行

相关推荐
牛奔3 小时前
Go 如何打印调试深层或嵌套的结构体
开发语言·后端·golang
geovindu4 小时前
go: Iterative Algorithms
开发语言·后端·算法·golang·迭代算法
学逆向的4 小时前
汇编——JCC指令
开发语言·汇编·网络安全
mayaairi5 小时前
JS循环语句深度解析:嵌套for、while与do...while
开发语言·前端·javascript
郭老二5 小时前
【Python】基本语法:装饰器语法糖@
python
kite01215 小时前
Go语言Map深度解析与最佳实践
开发语言·后端·golang
_Jimmy_6 小时前
Agent常用检索器的详细介绍
python·langchain
小柯南敲键盘7 小时前
图片翻译API接入与自动化实现指南
运维·python·自动化
l156469487 小时前
突围!图文混合知识库难以解析,Kimi-K3 原生视觉架构深耕知识工作,DMXAPI 统一接口,缩短项目开发周期
java·大数据·开发语言
旅僧7 小时前
Q-learning(自用)
python·机器学习