Show Menu
Cheatography

Python useful tips Cheat Sheet (DRAFT) by

Python useful tips

This is a draft cheat sheet. It is a work in progress and is not finished yet.

change current directory (Up)

#1st method
import os
print(os.path.dirname(os.getcwd()))
os.chdir(os.path.dirname(os.getcwd()))
print(os.path.dirname(os.getcwd()))

#2n method. several ups
import os
print(os.path.abspath(os.curdir))
os.chdir("../../..")
print(os.path.abspath(os.curdir))
 

Under constr­uct­ion...

more will come