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

@浙大疏锦行

相关推荐
程序员杰哥7 小时前
Python自动化测试之线上流量回放:录制、打标、压测与平台选择
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·压力测试
吴佳浩7 小时前
LangChain v1 重大更新讲解⚠⚠⚠
python·langchain·agent
智商低情商凑9 小时前
Go学习之 - Goroutines和channels
开发语言·学习·golang
半桶水专家9 小时前
Go 语言时间处理(time 包)详解
开发语言·后端·golang
编程点滴9 小时前
Go 重试机制终极指南:基于 go-retry 打造可靠容错系统
开发语言·后端·golang
顾安r9 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
实心儿儿9 小时前
C++ —— 模板进阶
开发语言·c++
萧鼎10 小时前
Python PyTesseract OCR :从基础到项目实战
开发语言·python·ocr
二川bro10 小时前
第57节:Three.js企业级应用架构
开发语言·javascript·架构
sali-tec10 小时前
C# 基于halcon的视觉工作流-章62 点云采样
开发语言·图像处理·人工智能·算法·计算机视觉