Answers for "how to get a files parent path python"

1

python extract thefile name from relative path

import os
infile = "./../../../../_data/matrix_data/5mer_normalized.tsv"
print(os.path.basename(infile))
>>> "5mer_normalized.tsv"
Posted by: Guest on October-17-2020
0

import file from parent directory python

import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# import ../db.py
import db
Posted by: Guest on June-18-2020

Code answers related to "how to get a files parent path python"

Python Answers by Framework

Browse Popular Code Answers by Language