Skip to content

模块基础:import ​

python
# math_utils.py
def add(a, b):
    return a + b

# main.py
import math_utils
print(math_utils.add(1, 2))

# 或
from math_utils import add
print(add(1, 2))

模块搜索路径 ​

python
import sys
print(sys.path)

练习:答案

用心记录每一步成长