python 路径引用问题

文件结构

入口文件·

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

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()
posted @ 2019-07-23 14:20  潘峰YiRan  阅读(1084)  评论(0编辑  收藏  举报