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

@浙大疏锦行

相关推荐
Generalzy1 小时前
langchain deepagent框架
人工智能·python·langchain
栈与堆1 小时前
LeetCode 19 - 删除链表的倒数第N个节点
java·开发语言·数据结构·python·算法·leetcode·链表
一路向北·重庆分伦1 小时前
03-01:MQ常见问题梳理
java·开发语言
txinyu的博客1 小时前
结合游戏场景理解,互斥锁,读写锁,自旋锁,CAS / 原子变量,分段锁
开发语言·c++·游戏
阿里嘎多学长1 小时前
2026-01-11 GitHub 热点项目精选
开发语言·程序员·github·代码托管
yuanyikangkang1 小时前
STM32 lin控制盒
开发语言
万行1 小时前
机器学习&第二章线性回归
人工智能·python·机器学习·线性回归
nervermore9901 小时前
3.3 Python图形编程
python
zhengfei6111 小时前
世界各地免费电视频道的 M3U 播放列表。
python