python 获取当前目录_如何在Python中获取当前的工作目录?
生活随笔
收集整理的這篇文章主要介紹了
python 获取当前目录_如何在Python中获取当前的工作目录?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python 獲取當前目錄
To get the current working directory in Python, there is a library function getcwd() in the os module.
為了在Python中獲得當前的工作目錄, os模塊中有一個庫函數getcwd() 。
getcwd() function does not accept any parameter and returns the path of the current working directory as string i.e. it’s return type is <class str>.
getcwd()函數不接受任何參數,并以字符串形式返回當前工作目錄的路徑,即其返回類型為<class str> 。
Syntax:
句法:
# import statementimport os# function callos. getcwd()Python代碼獲取當前工作目錄 (Python code to get current working directory)
# Python code to get # current working directory# importing the module import os# getting the current path current_path = os.getcwd()print("Current working directory is:", current_path)# printing the type of getcwd() function print("Type of \'getcwd()\' function is:", type(os.getcwd()))Output
輸出量
Current working directory is: /home/runner/FrenchBrightDaemon Type of 'getcwd()' function is: <class 'str'>翻譯自: https://www.includehelp.com/python/how-to-get-current-working-directory-in-python.aspx
python 獲取當前目錄
總結
以上是生活随笔為你收集整理的python 获取当前目录_如何在Python中获取当前的工作目录?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C程序对整数中设置为1的位数进行计数
- 下一篇: np.copysign_带有Python