This seems to be a simple question but I can't find any answer online. Suppose my current working directory is C:/parent_folder/sub_folder
, and I want to get C:/parent_folder
in Julia.
Edit: I have a solution using PyCall but are there any better solutions, preferably without the need of importing libraries of other languages?
using PyCall
function get_parent_directory()
pathlib = pyimport("pathlib")
path = pathlib.Path(pwd())
s = string(path.parent)
return split(s, "\'")[2]
end
get_parent_directory()