“Obtenha o diretório atual Python” Respostas de código

Obtenha WD em Python

import os

path = os.getcwd()

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

print(type(path))
# <class 'str'>
Happy Hawk

python obtenha diretório atual

import os

print(os.getcwd())
Busy Bat

Obter caminho para o diretório atual Python

import os
os.path.abspath(os.getcwd())
A

Obtenha Diroctary em Python

import os
cwd = os.getcwd()
print(cwd)
Jealous Jackal

Diretório de trabalho Python

import os
cwd = os.getcwd()
Happy Hawk

Obtenha o diretório atual 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")
Psych4_3.8.3

Respostas semelhantes a “Obtenha o diretório atual Python”

Perguntas semelhantes a “Obtenha o diretório atual Python”

Mais respostas relacionadas para “Obtenha o diretório atual Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código