python 路径引用问题

文件结构

python 路径引用问题_第1张图片

入口文件·

将当前文件的父级,加入搜索目录里面

import sys
import os
current_dir = os.path.abspath(os.path.dirname(__file__))
print(current_dir)  #F:\project\pritice
sys.path.append(current_dir+'/..')


# sys.path.append(r'F:\python历程\python基础\模块理解\one')

import package_runoob.runoob1 as runoob1
import package_runoob.runoob2 as runoob2

runoob1.runoob1()
runoob2.runoob2()

转载于:https://www.cnblogs.com/panfengde/p/11231493.html

你可能感兴趣的:(python 路径引用问题)