Ottieni la directory corrente python

Esempi di codice

24
0

ottieni wd in python

import os

path = os.getcwd()

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

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

directory di lavoro python

import os
cwd = os.getcwd()
8
0

python ottiene la directory corrente

import os

print(os.getcwd())
5
0

ottieni diroctary in python

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

ottieni il percorso della directory corrente python

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

ottieni la directory corrente python

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")

In altre lingue

Questa pagina è in altre lingue

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