“Direktori Kerja Python saat ini” Kode Jawaban

Dapatkan WD di Python

import os

path = os.getcwd()

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

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

Python Dapatkan Direktori Saat Ini

import os

print(os.getcwd())
Busy Bat

Python Direktori Bekerja

import os
cwd = os.getcwd()
Happy Hawk

Dapatkan Direktori File Python

import os 
dir_path = os.path.dirname(os.path.realpath(__file__))
Agreeable Ape

OS Dapatkan direktori saat ini

import os

#Get Current working Directory
currentDirectory = os.getcwd()

#Change the Current working Directory
os.chdir('/home/varun')
Agreeable Alpaca

Direktori Kerja Python saat ini

# If by "current working directory" you mean 
# the directory in which is saved the script in execution, then:
import os
cwd = os.path.dirname(os.path.realpath(__file__))
print(cwd)
Cheerful Chipmunk

Jawaban yang mirip dengan “Direktori Kerja Python saat ini”

Pertanyaan yang mirip dengan “Direktori Kerja Python saat ini”

Lebih banyak jawaban terkait untuk “Direktori Kerja Python saat ini” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya