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

@浙大疏锦行

相关推荐
咖啡续命又一天9 分钟前
python 自动化采集 ChromeDriver 安装
开发语言·python·自动化
huohaiyu39 分钟前
synchronized (Java)
java·开发语言·安全·synchronized
_OP_CHEN1 小时前
C++基础:(九)string类的使用与模拟实现
开发语言·c++·stl·string·string类·c++容器·stl模拟实现
蓝天智能1 小时前
QT MVC中View的特点及使用注意事项
开发语言·qt·mvc
松果集1 小时前
【1】数据类型2
python
且慢.5891 小时前
命令行的学习使用技巧
python
木觞清1 小时前
喜马拉雅音频链接逆向实战
开发语言·前端·javascript
海琴烟Sunshine2 小时前
leetcode 66.加一 python
python·算法·leetcode
wuxuanok2 小时前
苍穹外卖 —— 公共字段填充
java·开发语言·spring boot·spring·mybatis
偷光2 小时前
浏览器中的隐藏IDE: Console (控制台) 面板
开发语言·前端·ide·php