Python change current directory(up to parent) 3 Examples
https://blog.softhints.com/python-cha...
os.chdir("..")
pathlib - p.parent
os.chdir(os.path.dirname(os.getcwd()))
Example 1
import os
print(os.path.abspath(os.curdir))
os.chdir("..")
print(os.path.abspath(os.curdir))
Example 2
from pathlib import Path
p = Path("/home/user/myfile.txt")
print(p.parent)
print(p.parent.parent)
Example 3
import os
print(os.path.dirname(os.getcwd()))
os.chdir(os.path.dirname(os.getcwd()))
print(os.path.dirname(os.getcwd()))
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Code store
https://bitbucket.org/softhints/
Socials
Facebook: / 435421910242028
Facebook: / softhints
Twitter: / softwarehints
Discord: / discord
If you really find this channel useful and enjoy the content, you're welcome to support me and this channel with a small donation via PayPal.
PayPal donation https://www.paypal.me/fantasyan
Nesta página do site você pode assistir ao vídeo on-line Python 3 Simple Examples get current folder and go to parent duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Softhints - Python, Linux, Pandas 12 Setembro 2018, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 2,305 vezes e gostou 13 espectadores. Boa visualização!