python string manipulation - get parent directory of files in subfolders of

Also encountered before, and now use them only feel beautiful.

from os import sep, path as p

json_path = p.join(sep.join(p.abspath(__file__).split(sep)[:-2]), 'db', 'books.json')

 

Guess you like

Origin www.cnblogs.com/hercules-chung/p/12393321.html