Get current directory

Przykłady kodu

24
0

Pobierz wd w Pythonie

import os

path = os.getcwd()

print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook

print(type(path))
# <class 'str'>
15
0

working directory python

import os
cwd = os.getcwd()
8
0

python get current directory

import os

print(os.getcwd())
5
0

Pobierz diroctary w Pythonie

import os
cwd = os.getcwd()
print(cwd)
3
0

Pobierz ścieżkę do bieżącego katalogu python

import os
os.path.abspath(os.getcwd())
2
0

get current directory

import os
current_working_directory = os.getcwd()
print(current_working_directory) # should print the cwd

""" Bonus: If you want to change cwd, without moving file,
use the following method"""
os.chdir("path/to/directory")

W innych językach

Ta strona jest w innych językach

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................