On this page
os.getcwd
Prev: os.fspath | Up: os | Next: os.getenv
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.getcwd
Tags: #public #python3 #stdlib #os
Import
import os
from os import getcwd
Signature & Overview
os.getcwd()
Return a unicode string representing the current working directory.
Usage
import os
cwd = os.getcwd()
assert isinstance(cwd, str) and len(cwd) > 0
Gotchas
- Prefer
pathlib.Path.cwd(): Returns aPathobject ready for/joining.
REPL Inspect
from os import getcwd
help(getcwd)
Linked from
Related notes
- tuts/python3/stdlib_module/os/fspath Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/getenv Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib