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

@浙大疏锦行

相关推荐
不定积分要+C_yyy6 小时前
Java基础核心精讲:基本数据类型与包装类区别、自动装箱拆箱与缓存陷阱实战解析
java·开发语言
xingxiliang6 小时前
ReliableAgent:类似工程级可用的agent示例
java·开发语言·agent
buhuizhiyuci6 小时前
【python篇——一周速通python语法】python的基础语法操作
开发语言·python
程序猿编码7 小时前
没有AI框架,没有GPU,一个C语言文件跑通大模型
c语言·开发语言·人工智能·深度学习·ai·大模型
zmzb01037 小时前
C++课后习题训练记录Day160
开发语言·c++
沫璃染墨7 小时前
现代C++⊂C++11篇(一)列表初始化全解 & std::initializer_list
开发语言·c++
阿米亚波7 小时前
【C++ STL】std::forward_list
开发语言·c++·笔记·stl·visual studio·forward_list
盼小辉丶7 小时前
OpenCV-Python实战——分析与加速OpenCV应用程序
python·神经网络·opencv·计算机视觉
buhuizhiyuci7 小时前
【python篇——一周速通python语法】python的条件语句和循环语句
开发语言·python
geovindu7 小时前
go: Recursion Algorithm
开发语言·后端·算法·golang·递归算法