Re: [问题] 请问为何os.getcwd()不总在sys.path内?

楼主: cutekid (可爱小孩子)   2018-06-18 14:17:36
import os,sys,inspect
#####################################
# get file dir then add relative path
file = inspect.getfile(inspect.currentframe())
pathdir = os.path.dirname(os.path.abspath(file)) + '/..'
sys.path.insert(0,pathdir)
####################
# import your module
import say_hello
say_hello.hello_world()
※ 引述《clsmbstu (missing)》之铭言:
: 假设我有一个资料夹(helloworld)在桌面上,结构如下:
: helloworld
: |
作者: justoncetime (台北丛林好冷~)   2018-06-18 15:58:00
推标色
作者: clsmbstu   2018-06-21 18:00:00
感谢 我再研究一下

Links booklink

Contact Us: admin [ a t ] ucptt.com