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

@浙大疏锦行

相关推荐
Pniubi17 分钟前
Java为什么要分堆和栈
java·开发语言
用户2986985301442 分钟前
Python 自动化处理 Word 页眉页脚的几种典型场景
后端·python·api
小小晓.1 小时前
Qt 对话框、QLineEdit 与布局管理实战详解
开发语言·qt
終不似少年遊*1 小时前
【安全业务Agent】从场景到编排
python·react.js·ai·langchain·agent·安全架构·工作流
AKA__Zas1 小时前
接口自动化测试(1.0 初认识
python·ci/cd·学习方法
炸薯条!1 小时前
博客系统测试报告
开发语言·lua
Evand J2 小时前
【MATLAB例程12】永磁同步电机基于增广无迹卡尔曼滤波的未知负载转矩在线观测
开发语言·matlab
用户0332126663672 小时前
使用 Python 在 Excel 文档中添加水印
python·excel
高洁012 小时前
自然语言处理的技术演进与核心任务
人工智能·python·深度学习·机器学习·迁移学习
vipxieliang2 小时前
Python 类型注解与 mypy:提升代码可维护性
python