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