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

@浙大疏锦行

相关推荐
FuckPatience33 分钟前
Visual Studio C# 项目中文件后缀简介
开发语言·c#
ZhengEnCi4 小时前
M3-markconv库找不到wkhtmltopdf问题
python
2301_764441337 小时前
LISA时空跃迁分析,地理时空分析
数据结构·python·算法
014-code7 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024068 小时前
组合模式(Composite Pattern)
开发语言
游乐码8 小时前
c#泛型约束
开发语言·c#
Dontla8 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen8 小时前
python rest请求、requests
开发语言·python
cTz6FE7gA8 小时前
Python异步编程:从协程到Asyncio的底层揭秘
python
铁东博客8 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang